[Haskell] Re: Crazy class stuff

Claus Reinke claus.reinke at talk21.com
Tue Mar 13 06:48:16 EDT 2007

>And this works, and I don't know why:

mostly because you have pushed more possible conflicts till later - you could also have 
added Monad b, Monad (t b) to the context for the second instance in your previous 
version; shifting the constraints from the class to the method delays the point at which
they are checked (definition vs use).

if the Monad instances are really missing when you try to use that method, it will be
picked up later; also,  there is a potential instance overlap, as the more eager Hugs 
will tell you for the definitions, while GHC will also report that later, only if it occurs 
in use.


>class MonadTrans' i o where
>    lift' :: (Monad i, Monad o) => i a -> o a
>instance Monad m => MonadTrans' m m where
>    lift' = id
>instance (MonadTrans t, Monad b, MonadTrans' a b) => MonadTrans' a (t b) where
>    lift' = lift . lift'

More information about the Haskell mailing list