Thank you ! Is what I'm trying to do a common technique to type-ensure contexts or are there simpler methods?
2011/3/2 Max Bolingbroke <[email protected]> > On 2 March 2011 09:11, Yves Parès <[email protected]> wrote: > > class (forall x. Monad (IM i x)) => Impl i where > > data IM i :: * -> * -> * > > > > But GHC forbids me to do so. > > The way I usually work around this is by doing something like the > following pattern: > > {{{ > class Monad1 m where > return1 :: a -> m x a > bind1 :: m x a -> (a -> m x b) -> m x b > > instance Monad1 (IM MyI) where > return1 = ... > bind1 = ... > > instance Monad1 m => Monad (m x) where > return = return1 > (>>=) = bind1 > }}} > > Your class can now have a (Monad1 (IM i)) superclass context. You will > have to enable a few extensions to get this through - most likely > FlexibleInstances and OverlappingInstances. > > Cheers, > Max >
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
