Negative literals and the meaning of case -2 of -2 -> True

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Mon, 20 May 2002 18:45:32 +0100


Thomas Hallgren <hallgren@cse.ogi.edu> writes:

>     * hugs Dec 2001: main outputs: (FromInteger (-2),True)
>     * ghc 5.02.2: main outputs: (FromInteger (-2),True)
>     * hbc 0.9999.5b: main outputs: (Negate (FromInteger 2),False)
>     * nhc98 1.12: compiler outputs: Fail: What? matchAltIf at 7:13
> 
>  From this I conclude that hbc is the only Haskell implementation that 
> treats negated literals in expressions in accordance with the report, 
> but it treats negated literals in patterns differently. Hugs and ghc 
> treat expressions and patterns consistently, but they disagree with the 
> report. Nhc98 appears to be buggy.

nhc98 (1.12) does appear to have a slight bug here, but it is only
in the compilation of the pattern-match.  If you exclude the pattern
from your test, the output is (Negate (FromInteger 2)), which agrees
with hbc and the Report.

In addition, the CVS version now has a fix for the pattern-match bug,
and the result of trueOrFalse is True, as expected.

Regards,
    Malcolm