(no subject)
Glynn Clements
glynn.clements@virgin.net
Fri, 13 Sep 2002 20:17:10 +0100
Richard Barth wrote:
> I'm just learning Haskell with Hugs98. I can't understand why the line
> defining "foo" is acceptable while the line defining "bar" (only
> difference is the unary minus) generates the error message at the end.
> If someone could explain this, or, better yet, tell me how I can figure
> this out for myself. Thanks.
>
> data Entry = Ent {date :: String, amount :: Double}
> foo = [Ent "baz" 1.0]
> bar = [Ent "baz" -1.0]
bar = [Ent "baz" (-1.0)]
A "-" is normally interpreted as the binary subtraction operator
rather than the unary negation operator. Most of the time, negative
literals need to be enclosed in parentheses.
--
Glynn Clements <glynn.clements@virgin.net>