
13 Sep
2002
13 Sep
'02
3:17 p.m.
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