On , oleg@okmij.org wrote:
> [...]
> Exactly this code is implemented in Example.hs. Here's an excerpt:
>
>
>
> > -- Default instance
>
>
>
> > instance (Monad (t m), MonadState m, MonadTrans t)
>
> > => MonadState' (t m) HFalse where
>
> > type MState' (t m) HFalse = MState m
>
> > get' _ = trace "Default get" $ lift get
>
> > put' _ = lift . put
>
> >
>
> > -- Special instances
>
> >
>
> > instance (Monad m)
>
> > => MonadState' (StateT s m) HTrue where
>
> > type MState' (StateT s m) HTrue = s
>
> > get' _ = trace "Special get" . StateT $ \s -> return (s, s)
>
> > put' _ s = StateT $ \_ -> return ((), s)
>
> >
>
> > -- add more special instances if needed ...
>
>
>
> plus one more general dispatching instance. Because of the additional
>
> flag, HTrue vs HFalse, the above instances do not overlap.
Can you add more special instances for types that match (t m) without using OverlappingInstances and without modifying the instances you have above?