<p>I think you'll find a problem using do-notation with your Monad.</p>
<p>Tony Morris</p>
<p><blockquote type="cite">On 04/01/2011 11:33 PM, "Alexey Khudyakov" <<a href="mailto:alexey.skladnoy@gmail.com">alexey.skladnoy@gmail.com</a>> wrote:<br><br><p><font color="#500050">On 04.01.2011 13:24, <a href="mailto:oleg@okmij.org">oleg@okmij.org</a> wrote:<br>
><br>><br>> I'd like to argue in opposition of making Functor a...</font></p>
I think I understood your point. But it looks like that it's possible to use subclass's function in superclass instance. At very least GHC is able to do it.<br>
<br>
Following example works just fine without any language extensions in GHC6.12.3<br>
<br>
<br>
import Prelude hiding (Monad(..), Functor(..))<br>
<br>
class Functor f where<br>
fmap :: (a -> b) -> f a -> f b<p><font color="#500050"><br><br>class Functor m => Monad m where<br> return :: a -> m a<br> (>>=) :: m a -> (a -> m b) -> m b<br></font></p>
instance Functor Maybe where<p><font color="#500050"><br> fmap f m = m >>= (return . f)</font></p>
instance Monad Maybe where<br>
return = Just<br>
Nothing >>= _ = Nothing<br>
Just x >>= f = f x<p><font color="#500050"><br><br>_______________________________________________<br>Haskell-prime mailing list<br>Haskell-prime@haskell.o...</font></p></blockquote></p>