I believe the incompatibilities are explained thus: In section 4.5.1 of the Haskell Report it only states that "A dependency analysis transformation is first performed to increase polymorphism" But hugs appears to be using a more refined version of the dependency analysis as explained in section 11.6.3 of Mark Jones' paper Typing Haskell in Haskell. Read that section. - Mark Arthur Baars wrote:
In Mark Jones' paper Typing Haskell in Haskell, I found the following example(in the section on binding-groups):
f :: Eq a => a -> Bool f x = x==x || g True g y = y<=y || f True
According to the paper the inferred type of g should be: g::Ord a => a -> Bool
Hugs infers this type but GHC infers the following *ambiguous* type: *Main> :i g -- g is a variable, defined at Test.hs:25 g :: forall a. (Eq a) => Bool -> Bool
When adding an explicit type signature for g, Hugs happily accepts the code, but GHC gives the following error:
f :: Eq a => a -> Bool f x = x==x || g True g :: Ord a => a -> Bool g y = y<=y || f True
Test.hs:24: Couldn't match `{Ord a}' against `{Eq a1}' When matching the contexts of the signatures for g :: forall a. (Ord a) => a -> Bool f :: forall a. (Eq a) => a -> Bool The signature contexts in a mutually recursive group should all be identical When generalising the type(s) for g, f Failed, modules loaded: none.
I think the problems are caused by differences in the binding group analysis in Hugs and GHC.
Malcolm, could you check what NHC says about the examples above?
Cheers, Arthur
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell