[Haskell-beginners] change to wikibook?

Brent Yorgey byorgey at seas.upenn.edu
Sat May 12 22:35:30 CEST 2012


On Sat, May 12, 2012 at 10:15:42PM +0200, Ashley Smith wrote:
> I was wondering if someone could explain this error? I typed in the sample
> code from the Haskell Beginning Wikibook to define a function for absolute
> value. I have GHC 7.0.4 for OSX. The error went away when I put parentheses
> around the negative value, so did the Haskell interpreter think I was
> entering - and a second argument, namely 10, when the parentheses weren't
> there? Thank you!

Exactly.  This is a rather ugly corner of Haskell's lexical syntax,
but it matches the official specification.  Negative numbers often
require parentheses around them so that the negation symbol does not
parse as subtraction.

If the wikibook itself actually lists "abs -10" as an example for you
to try out, it should be fixed.

-Brent



More information about the Beginners mailing list