> To find out how Haskell implementations treat negated
> literals, I tested
> the following program:
>
> ------------------------------------------------
> main = print (minusTwo,trueOrFalse)
>
> minusTwo = -2::N
>
> trueOrFalse =
> case minusTwo of
> -2 -> True
> _ -> False
>
> data N = Negate N | FromInteger Integer deriving (Eq,Show)
>
> instance Num N where
> negate = Negate
> fromInteger = FromInteger
> -------------------------------------------------
>
> The result is:
>
> * ghc 5.02.2: main outputs: (FromInteger (-2),True)
GHC has two bugs in this area, one of which has been fixed recently.
The current output is (Negate (FromInteger 2),False) (i.e. the same as
hbc). We were being a little too eager to replace 'negate (fromInteger
N)' by 'fromInteger (-N)'. There is also a bug in the pattern handling,
however.
Thanks for a nice test case...
Cheers,
Simon
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell