I think you'll find a problem using do-notation with your Monad.

Tony Morris

On 04/01/2011 11:33 PM, "Alexey Khudyakov" <alexey.skladnoy@gmail.com> wrote:

On 04.01.2011 13:24, oleg@okmij.org wrote:
>
>
> I'd like to argue in opposition of making Functor a...

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.

Following example works just fine without any language extensions in GHC6.12.3


import Prelude hiding (Monad(..), Functor(..))

class Functor f where
 fmap :: (a -> b) -> f a -> f b



class Functor m => Monad m where
 return :: a -> m a
 (>>=) :: m a -> (a -> m b) -> m b

instance Functor Maybe where


 fmap f m = m >>= (return . f)

instance Monad Maybe where
 return = Just
 Nothing >>= _ = Nothing
 Just x  >>= f = f x



_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.o...