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 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.
>
>
> I'd like to argue in opposition of making Functor a...
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 binstance Functor Maybe where
class Functor m => Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m binstance Monad Maybe where
fmap f m = m >>= (return . f)
return = Just
Nothing >>= _ = Nothing
Just x >>= f = f x
_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.o...