
Hi, The following expression evaluates to 1 in GHCi, but results in an error in Hugs: let f x = let g y = [x,y] in (g 1, g []) in 1 What is the correct behavior? Thanks Vladimir

http://haskell.org/onlinereport/exps.html#sect3.12 "Pattern bindings are matched lazily; an implicit ~ makes these patterns irrefutable. For example, let (x,y) = undefined in e does not cause an execution-time error until x or y is evaluated." So GHCi is correct. Dan Vladimir Reshetnikov wrote:
Hi,
The following expression evaluates to 1 in GHCi, but results in an error in Hugs:
let f x = let g y = [x,y] in (g 1, g []) in 1
What is the correct behavior?
Thanks Vladimir _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Am Freitag 29 Mai 2009 20:35:47 schrieb Dan Weston:
http://haskell.org/onlinereport/exps.html#sect3.12
"Pattern bindings are matched lazily; an implicit ~ makes these patterns irrefutable. For example,
let (x,y) = undefined in e
does not cause an execution-time error until x or y is evaluated."
So GHCi is correct.
Dan
It's not the matching that prdouces the error, Haskell 98 mode: Restart with command line option -98 to enable extensions Type :? for help Hugs> let f x = let g y = [x,y] in (g 1, g []) in 1 ERROR - Cannot infer instance *** Instance : Num [a] *** Expression : f Hugs> :q [Leaving Hugs] dafis@linux-mkk1:~/Haskell/CafeTesting> hugs -98 Hugs mode: Restart with command line option +98 for Haskell 98 mode Type :? for help Hugs> let f x = let g y = [x,y] in (g 1, g []) in 1 1 Hugs> :t \x -> let g y = [x,y] in (g 1, g []) \x -> let {...} in (g 1,g []) :: Num [a] => [a] -> ([[a]],[[a]]) Hugs> In Haskell98 mode, hugs looks for an instance Num [a] eagerly, doesn't find one and complains, while ghci is content with inferring a legal (though uninstantiated) type for the unused expression. In hugs mode, hugs does the same. I don't know if the standard requires or disallows either behaviour. If it does, one of the two is wrong, if it's left to the implementation, both are right.
Vladimir Reshetnikov wrote:
Hi,
The following expression evaluates to 1 in GHCi, but results in an error in Hugs:
let f x = let g y = [x,y] in (g 1, g []) in 1
What is the correct behavior?
Thanks Vladimir
participants (3)
-
Dan Weston
-
Daniel Fischer
-
Vladimir Reshetnikov