[Haskell-cafe] Type synonym family inside type class

Martijn van Steenbergen martijn at van.steenbergen.nl
Fri Nov 27 05:34:41 EST 2009


Hello,

I have a type family and a type class:

> type family ErrorAlg (f :: (* -> *) -> * -> *) e ix :: *

> class MkErrorAlg f where
>   mkErrorAlg :: ErrorAlg f e a -> f (K0 a) ix -> Either e a

Instances for these two really go hand in hand, so I thought I would 
move the type family into the type class. However, this causes GHC to 
complain about the type variables that are bound on the LHS of the type 
synonym:

> Not in scope: type variable `e'
> Not in scope: type variable `ix'

In function types, using new type variables (i.e. type variables not 
bound by the type class header) implicitly means universal 
quantification over these variables. Why is this disallowed in type 
families inside type classes?

Thanks,

Martijn.


More information about the Haskell-Cafe mailing list