That won't be a great idea; if I just want my monad to be declared as one, I
would have to write
instance Functor MyMonad where fmap = ...
instance Pointed MyMonad where pure = ...
instance Applicative MyMonad where (<*>) = ...
instance Monad MyMonad where join = ...
Compare this with
instance Monad MyMonad where
return = ...
(>>=) = ...
and take into account that (>>=) is usually easier to write than join.
Limestraƫl wrote:
Then it would be:
class Functor f where
fmap :: (a -> b) -> f a -> f b
class (Functor f) => Pointed f where
pure :: a -> f a
class (Pointed f) => Applicative f where
(<*>) :: f (a -> b) -> f a -> f b
class (Applicative f) => Monad f where
join :: f (f a) -> f a
This would be a great idea, for the sake of logic, first (a monad which
is not a functor doesn't make sense), and also to eliminate redudancy
(fmap = liftM, ap = (<*>), etc.)
2010/5/20 Tony Morris <tonymor...@gmail.com <mailto:tonymor...@gmail.com>>
Ivan Miljenovic wrote:
> On 20 May 2010 14:42, Tony Morris <tonymor...@gmail.com
<mailto:tonymor...@gmail.com>> wrote:
>
>> We all know that "class (Functor f) => Monad f" is preferable
but its
>> absence is a historical mistake. We've all probably tried once:
>>
>> instance (Functor f) => Monad f where
>>
>
> Do you mean the reverse of this (instance (Monad m) => Functor m
where) ?
>
Yes.
--
Tony Morris
http://tmorris.net/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org <mailto:Haskell-Cafe@haskell.org>
http://www.haskell.org/mailman/listinfo/haskell-cafe
------------------------------------------------------------------------
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe