TypeFamilies vs. FunctionalDependencies & type-level recursion

sanzhiyan at gmail.com sanzhiyan at gmail.com
Tue Jun 21 20:03:57 CEST 2011


On , oleg at 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-prime/attachments/20110621/3dcbdcfb/attachment.htm>


More information about the Haskell-prime mailing list