[Haskell-cafe] (no subject)

Vladimir Reshetnikov v.reshetnikov at gmail.com
Sun May 31 03:38:40 EDT 2009


Hi,

Seems that Haskell allows to specify "dummy" type variables in a
declaration of a type synonym, which do not appear in its right-hand
side. This can lead to interesting effects, which appears differently
in GHC and Hugs. I would like to know, what behavior is correct
according to the haskell 98 report.

1)
------------------------------------------
type F a = Int

class A a where
  foo :: A b => a (F b)
------------------------------------------

GHC - OK
Hugs - Illegal type "F b" in constructor application

2)
------------------------------------------
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]



Thanks,
Vladimir


More information about the Haskell-Cafe mailing list