[Haskell-cafe] (no subject)
Claus Reinke
claus.reinke at talk21.com
Sun May 31 06:17:45 EDT 2009
> ------------------------------------------
> type F a = Int
>
> class A a where
> foo :: A b => a (F b)
> ------------------------------------------
>
> GHC - OK
> Hugs - Illegal type "F b" in constructor application
This time, I'd say Hugs is wrong (though eliminating that initial
complaint leads back to an ambiguous and unusable method 'foo').
4.2.2 Type Synonym Declarations, lists only class instances as
exceptions for type synonyms, and 'Int' isn't illegal there.
> ------------------------------------------
> type F a = Int
>
> class A a where
> foo :: F a
>
> instance A Bool where
> foo = 1
>
> instance A Char where
> foo = 2
>
> xs = [foo :: F Bool, foo :: F Char]
> ------------------------------------------
>
> GHC:
>
> M.hs:14:6:
> Ambiguous type variable `a' in the constraint:
> `A a' arising from a use of `foo' at M.hs:14:6-8
> Probable fix: add a type signature that fixes these type variable(s)
>
> M.hs:14:21:
> Ambiguous type variable `a1' in the constraint:
> `A a1' arising from a use of `foo' at M.hs:14:21-23
> Probable fix: add a type signature that fixes these type variable(s)
>
> Hugs: [1,2]
Neither seems correct? 4.3.1 Class Declarations, says:
The type of the top-level class method vi is:
vi :: forall u,w. (C u, cxi) =>ti
The ti must mention u; ..
'foo's type, after synonym expansion, does not mention 'a'.
Claus
More information about the Haskell-Cafe
mailing list