[Haskell-cafe] Type synonym family inside type class

Martijn van Steenbergen martijn at van.steenbergen.nl
Fri Nov 27 09:16:10 EST 2009


Hi Sean,

Sean Leather wrote:
> Perhaps this isn't answering your question, but you can turn the above 
> into an associated type as follows.
> 
>     class MkErrorAlg f where
>       type ErrorAlg (f :: (* -> *) -> * -> *) :: * -> * -> *
>       mkErrorAlg :: ErrorAlg f e a -> f (K0 a) ix -> Either e a

That is true. But how would you translate the following instance to the 
new version?

> type instance ErrorAlg (K b   :*: f)  e a = b  -> ErrorAlg f e a

I don't know how to do that without introducing a new newtype that I can 
partially parametrize. I don't want to have to introduce a newtype for 
that, especially because it defeats the purpose of (in this specific 
case) generically deriving a user-friendly type.

Groetjes,

Martijn.


More information about the Haskell-Cafe mailing list