On , o...@okmij.org wrote:
[...] Exactly this code is implemented in Example.hs. Here's an excerpt:
> -- Default instance
> instance (Monad (tm), MonadState m, MonadTrans t)
> => MonadState' (tm) HFalse where
> type MState' (tm) HFalse = MState m
> get' _ = trace "Default get" $ lift get
> put' _ = lift . put
>
> -- Special instances
>
> instance (Monad m)
> => MonadState' (StateT sm) HTrue where
> type MState' (StateT sm) 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 (tm) without using OverlappingInstances and without modifying the instances you have above?
_______________________________________________ Haskell-prime mailing list Haskell-prime@haskell.org http://www.haskell.org/mailman/listinfo/haskell-prime