We were quite surprised when a student mnaged to get away with the
following (skeletal) definition:
sumsquares n | n < 0 = error "sumsquares:n < 0"
n | n >= 0 = n
since according to the Haskell report this either shouldn't parse, or
should parse as two definitions---one for "sumsquares" and one for "n"
(a twiddly bit of the report I didn't cross-reference). My only guess
is that this is a holdover from the Miranda-like days of Gofer. It
does confuse students whose code suddenly stops working when given to
a compiler...
Or am I totally misreading pp 46--48 of the report? (I note that hbc
and our compiler, both of which are at best Haskell 1.3 compliant
around here, parse this the same way as Hugs does---but I'm sure I've
seen complaints about this usage before.)
-Jan-Willem Maessen
Still doing Miranda-style pattern matching?
Jan-Willem Maessen Wed, 15 Oct 1997 20:59:57 +0200 (MET DST)
- Re: Still doing Miranda-style pattern matching? Jan-Willem Maessen
- Re: Still doing Miranda-style pattern matching? Heribert Schuetz
- Re: Still doing Miranda-style pattern matching? Lennart Augustsson
