>> GHC complains about:
>>
>> > class (Monad m, {-, Monad (t m)-}) => MonadT t m where
>> >   lift :: m a -> (t m) a
>> >
>> > instance (Monad m) => Monad (EnvT env m) where
>> >   ...
>> >
>> > instance (Monad (EnvT env m)) => MonadT (EnvT env) m where
>> >   ...
...
>OK, there are two things going on.  First, GHC is meant to implement
>the restriction that the context in an instance decl can constrain
>only type variables (Choice 6b).  So this should be illegal:
>
> instance (Monad (EnvT env m)) => MonadT (EnvT env) m where ...


Sorry, I overlooked that fact.

>Instead, since Monad (EnvT env m) holds if Monad m holds, you should
>write
>
> instance Monad m => MonadT (EnvT env) m where ...
>
>The complaint on import is because GHC didn't realise that it
>hadn't checked for a decent instance context, and thereby generated
>a bogus one in the interface file.


Even when I use the "decent" definition you suggest, GHC duplicates the
context:

8 $d2 _:_ _forall_ [a b :: (* -> *)] {PrelBase.Monad b, PrelBase.Monad b} =>
(MonadT (EnvT a) b) ;;

--FC


Reply via email to