[Haskell-cafe] Problems instancing a class

Roberto Zunino roberto.zunino at sns.it
Fri Feb 17 13:44:04 EST 2006

Juan Carlos Arevalo Baeza wrote:

 > type Context = HT.HashTable String String
 > Illegal instance declaration for `MyClass Context'
 >    (The instance type must be of form (T a b c)
 >     where T is not a synonym, and a,b,c are distinct type variables)
 > In the instance declaration for `MyClass Context'

"type" introduce a type synonym, and Haskell98 forbids these in 
instances, so GHC complains. GHC also lifts this restriction when 
invoked with -fglasgow-exts .


 >   If I use "data" instead of "type", it works:
 > data Context = C (HT.HashTable String String)

This is fine: data (and newtype) declarations do not introduce type 
synonyms, but a genuine new type.

Roberto Zunino.

More information about the Haskell-Cafe mailing list