
On Sat, May 12, 2012 at 4:15 PM, Ashley Smith
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!
If the WikiBook provided that as an example, then it's buggy and someone should fix it. This is a longstanding and difficult to fix annoyance of Haskel's syntax; the parenthese *are* required there. Briefly: unary operators don't work very well. It can't resolve them by context because it's not impossible for a function to typecheck there (nobody recommends Num instances for functions, but they're not forbidden either), and syntactically they conflict with sections (resolved in favor of the unary op, with the result that there's a function "subtract" that exists just to facilitate the (`subtract` 1) section.) What this adds up to is that you should be very careful around "-" because it's trying to satisfy too many mutually incompatible pieces of syntax. -- brandon s allbery allbery.b@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms