a trap for the unwary

Mark P Jones mpj@cse.ogi.edu
Fri, 1 Dec 2000 10:58:43 -0800

Hi Malcolm,

| Today, I thought I had discovered a bug in ghc.  Then I tried hbc
| and Hugs, and they also rejected my program with the same error.
| nhc98 alone accepts it without complaint.  I looked up the Report,
| and it seems that the program is indeed incorrect.
| > f x =3D y
| >   where
| >     y | isSpace x =3D True
| >     y | otherwise =3D False

For what it's worth, older versions of Hugs would have accepted this
too.  Only quite recently was it changed to conform to the report.

Incidentally, although the above is not valid Haskell, the following
should work just fine:

 f x =3D y
     y | isSpace x =3D True
       | otherwise =3D False

The difference is that I haven't repeated the left hand side of the
definition in the second equation, which means that it's treated as
one definition, not two.

All the best,

(PS.  An even nicer way to write this definition:  f =3D isSpace   :-)