Thank you !<br><br>Is what I'm trying to do a common technique to type-ensure contexts or are there simpler methods?<br><br><br><div class="gmail_quote">2011/3/2 Max Bolingbroke <span dir="ltr"><<a href="mailto:batterseapower@hotmail.com">batterseapower@hotmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On 2 March 2011 09:11, Yves Parès <<a href="mailto:limestrael@gmail.com">limestrael@gmail.com</a>> wrote:<br>
> class (forall x. Monad (IM i x)) => Impl i where<br>
> data IM i :: * -> * -> *<br>
><br>
> But GHC forbids me to do so.<br>
<br>
</div>The way I usually work around this is by doing something like the<br>
following pattern:<br>
<br>
{{{<br>
class Monad1 m where<br>
return1 :: a -> m x a<br>
bind1 :: m x a -> (a -> m x b) -> m x b<br>
<br>
instance Monad1 (IM MyI) where<br>
return1 = ...<br>
bind1 = ...<br>
<br>
instance Monad1 m => Monad (m x) where<br>
return = return1<br>
(>>=) = bind1<br>
}}}<br>
<br>
Your class can now have a (Monad1 (IM i)) superclass context. You will<br>
have to enable a few extensions to get this through - most likely<br>
FlexibleInstances and OverlappingInstances.<br>
<br>
Cheers,<br>
<font color="#888888">Max<br>
</font></blockquote></div><br>