PROPOSAL: Make Applicative a superclass of Monad
Ashley Yakeley
ashley at semantic.org
Tue Jun 24 21:16:54 EDT 2008
I had proposed this to the GHC Trac, but it was pointed out that it
would break Haskell 98. That proposal has been closed.
Proposal:
Make Applicative (in Control.Applicative) a superclass of Monad (in
Control.Monad). Rename members of Applicative and other functions, to
avoid unnecessary duplication. Generalise types of certain existing
functions, as appropriate.
For example:
class Functor f => Applicative f where
return :: a -> f a
ap :: f (a -> b) -> f a -> f b
(>>) :: f a -> f b -> f b
(>>) = liftA2 (const id)
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
liftA2 f a b = ap (fmap f a) b
-- etc.
class Applicative m => Monad m where
(>>=) :: m a -> (a -> m b) -> m b
fail :: String -> m a
fail s = error s
--
Ashley Yakeley
More information about the Haskell-prime
mailing list