seq and lambda with patterns

There is some subtle, but reasonable difference between \pat1 pat2 -> expr and \pat1 -> \pat2 -> expr:
seq ((\True y -> "DEFINED") undefined) 42 42 seq ((\True -> \y -> "DEFINED") undefined) 42 *** Exception: Prelude.undefined
The reason is the translation from Haskell Report 2010 (3.3) \ p1 . . . pn -> e = \ x1 . . . xn -> case (x1 , . . . , xn ) of (p1 , . . . , pn ) -> e Today I found (GHC 8.0.1) that
seq ((\True -> \y -> undefined) undefined) 42 42
Is the last result correct? -- Denis Moskvin

On Wed, Sep 28, 2016 at 03:00:57PM +0300, Denis Moskvin wrote:
There is some subtle, but reasonable difference between \pat1 pat2 -> expr and \pat1 -> \pat2 -> expr:
seq ((\True y -> "DEFINED") undefined) 42 42 seq ((\True -> \y -> "DEFINED") undefined) 42 *** Exception: Prelude.undefined
The reason is the translation from Haskell Report 2010 (3.3) \ p1 . . . pn -> e = \ x1 . . . xn -> case (x1 , . . . , xn ) of (p1 , . . . , pn ) -> e
Today I found (GHC 8.0.1) that
seq ((\True -> \y -> undefined) undefined) 42 42
Is the last result correct?
According to the Haskell report this is seq ((\x -> case x of True -> (\y -> undefined)) undefined) 42 and evaluation proceeds to case undefined of True -> (\y -> undefined)) and thus to undefined So I agree with you that there's something fishy here. Tom
participants (2)
-
Denis Moskvin
-
Tom Ellis