[Haskell-cafe] Hugs vs. GHCi
Daniel Fischer
daniel.is.fischer at web.de
Fri May 29 14:49:59 EDT 2009
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 at 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
More information about the Haskell-Cafe
mailing list