pattern matching
Levent Erkok
erkok@cse.ogi.edu
Tue, 28 Aug 2001 22:51:51 +0000
HUGS> let ~(1,x) = (2,3) in x
3
GHCI> let ~(1,x) = (2,3) in x
*** Exception: <no file>:0: Irrefutable pattern failed for pattern (1, x)
I think ghc is doing the right thing: the match should fail. Using the translation
of let into case as described in the report (section 3.12), one gets:
case (2, 3) of ~(~(1,x)) -> x
This expression should cause a pattern matching failure. But hugs evaluates it to 3.
Interestingly:
HUGS> case (2, 3) of ~(1,x) -> x
Program error: {v1309 (2,Num_fromInt instNum_v29 3)}
which is the correct behavior. Shouldn't multiple tilde's be the same as just one?
(Hugs version: out of the CVS repository.)
-Levent.