Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Just beginning problem

0 views
Skip to first unread message

Chris Saunders

unread,
Oct 17, 2009, 5:52:52 PM10/17/09
to
I am just beginning to learn Haskell. Just for starters I'm watching a
video lecture from Channel 9. The lecturer defines a function like this
"myadd (x,y) = x + y". When I enter this into GHCi I get the error message
":1:12: parse error on input `='". Could I get a simple explanation of
this?

Regards
Chris Saunders

Mark T. B. Carroll

unread,
Oct 17, 2009, 6:14:47 PM10/17/09
to
"Chris Saunders" <ev...@mountaincable.net> writes:

When typing functions into GHCi, add a `let' in front:

Prelude> let myadd (x,y) = x + y
Prelude> :info myadd
myadd :: (Num t) => (t, t) -> t -- Defined at <interactive>:1:4-8
Prelude>

If you put it in a file instead and use :load to load it (or :reload to
reload it), you don't put the `let' in the definition in the file.

Mark

Chris Saunders

unread,
Oct 17, 2009, 6:42:55 PM10/17/09
to
I very much appreciate your help. I'm afraid I may be full of dumb
questions for awhile. For a little while, I don't think I'll be trying to
create any source files but I'll try to remember the tip.

Regards
Chris Saunders

"Mark T. B. Carroll" <Mark.C...@Aetion.com> wrote in message
news:87aazpy...@ixod.org...

Paul Rubin

unread,
Oct 17, 2009, 7:05:20 PM10/17/09
to
"Chris Saunders" <ev...@mountaincable.net> writes:
> I very much appreciate your help. I'm afraid I may be full of dumb
> questions for awhile. For a little while, I don't think I'll be
> trying to create any source files but I'll try to remember the tip.

IRC might be a better place than Usenet to seek this kind of help. If
you have an IRC client, hang out on #haskell. It is a friendly place
and you'll learn a lot.

Mark T. B. Carroll

unread,
Oct 17, 2009, 7:23:44 PM10/17/09
to
"Chris Saunders" <ev...@mountaincable.net> writes:

> I very much appreciate your help. I'm afraid I may be full of dumb
> questions for awhile. For a little while, I don't think I'll be trying to
> create any source files but I'll try to remember the tip.

No problem, dumb questions are at least quickly answered. (-:

So what is this Channel 9 that teaches Haskell? Sounds intriguing.

Mark

Paul Rubin

unread,
Oct 17, 2009, 7:32:34 PM10/17/09
to
"Mark T. B. Carroll" <Mark.C...@Aetion.com> writes:
> So what is this Channel 9 that teaches Haskell? Sounds intriguing.

http://channel9.msdn.com/

Mark T. B. Carroll

unread,
Oct 17, 2009, 10:15:44 PM10/17/09
to

Oh, an online Microsoft community thing, thank you! And I had been
wondering if it was some local public access station. (Ours happens to
be on channel 9 on cable.)

Mark

Ertugrul Söylemez

unread,
Oct 18, 2009, 1:04:06 AM10/18/09
to
"Chris Saunders" <ev...@mountaincable.net> wrote:

Your original question has been answered. I just like to add something
very important.

Simply put, this is not the way you would define a 'myAdd' function in
Haskell. Your function doesn't take two arguments, but only one
argument, a tuple of two numbers, notated by (x, y). Here is how to do
it properly:

myAdd x y = x + y

What is the difference, you may ask. It's currying. If you define it
the way you did, you lose the advantages of curried style, one of which
is more concise source code, another one is partial application. You
couldn't use the following statements:

myAdd 3 5
Results in 8, you would need to write myAdd (3, 5).

myAdd 3
Results in a function, which adds 3 to its argument. This is called
partial application, one of the key features of currying.

3 `myAdd` 5
Infix notation for binary functions. Doesn't make sense for your
definition, because your variant of myAdd takes only one argument,
namely a tuple.

Functional programming tutorials on the MSDN are usually totally
brain-damaged, even for Microsoft's own language F#. Even though F#
supports currying, they don't promote its use and still use the obsolete
uncurried style. It seems like the tutorial authors don't understand
the language themselves. Interestingly even F#'s design is highly
influenced by this incompetence, which makes the language frustrating to
use, even though it would have potential.

I recommend learning from other sources.


Greets,
Ertugrul.


--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://blog.ertes.de/

Chris Saunders

unread,
Oct 18, 2009, 3:13:03 PM10/18/09
to
I rather like this suggestion. I have never used IRC. Could you suggest a
program to use on Windows. Right now I am having a few difficulties that
I'm almost ashamed to ask about.

Regards
Chris Saunders

"Paul Rubin" <http://phr...@NOSPAM.invalid> wrote in message
news:7xvdidi...@ruckus.brouhaha.com...

Dirk Thierbach

unread,
Oct 18, 2009, 3:26:42 PM10/18/09
to
Chris Saunders <ev...@mountaincable.net> wrote:
> I rather like this suggestion. I have never used IRC. Could you suggest a
> program to use on Windows. Right now I am having a few difficulties that
> I'm almost ashamed to ask about.

Don't be ashamed, just ask. There are no dumb questions, just dumb answers.

I'm not using Windows, but AFAIK, "mirc" is a popular client for Windows.

- Dirk

Chris Saunders

unread,
Oct 18, 2009, 3:37:46 PM10/18/09
to
Thanks for the tip. Perhaps the information on MSDN is not a brain damaged
as you think. What you spoke about is described and spoken about in the
lecture series I was watching. I was just trying to enter some of the
example code shown into GHCi. I am reading the manual for GHCi but have not
gotten very far with that yet.

Regards
Chris Saunders

"Ertugrul S�ylemez" <e...@ertes.de> wrote in message
news:20091018070...@tritium.xx...

Mark T. B. Carroll

unread,
Oct 18, 2009, 3:50:15 PM10/18/09
to
Dirk Thierbach <dthie...@usenet.arcornews.de> writes:

> Chris Saunders <ev...@mountaincable.net> wrote:
>> I rather like this suggestion. I have never used IRC. Could you suggest a
>> program to use on Windows. Right now I am having a few difficulties that
>> I'm almost ashamed to ask about.
>
> Don't be ashamed, just ask. There are no dumb questions, just dumb answers.

Quite, if you're making a good effort to try, we'll still be able to
tell even if the questions are dumb. And for what it's worth, I've asked
my fair share of dumb questions too. (-:

Mark

Mark T. B. Carroll

unread,
Oct 19, 2009, 4:22:30 PM10/19/09
to
"Mark T. B. Carroll" <Mark.C...@Aetion.com> writes:

> dumb questions are at least quickly answered.

For instance, seeing intersectBy, etc., I was just wondering aloud where
differenceBy is, only for it to be pointed out to me that it's
deleteFirstsBy. (In my defense, Hayoo was down at the time. (-:)

Mark

0 new messages