PROPOSAL: Make Applicative a superclass of Monad
ashley at semantic.org
Tue Jun 24 05:15:19 EDT 2008
Make Applicative (in Control.Applicative) a superclass of Monad (in
Control.Monad). Rename members of Applicative and other functions, to
avoid unnecessary duplication.
class Functor f => Applicative f where
return :: a -> f a
ap :: f (a -> b) -> f a -> f b
liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
liftA2 f a b = ap (fmap f a) b
(>>) :: (Applicative f) => f a -> f b -> f b
(>>) = liftA2 (const id)
class Applicative m => Monad m where
(>>=) :: m a -> (a -> m b) -> m b
fail :: String -> m a
fail s = error s
I do not have a patch for this change, as it involves mucking around
with GHC.Base, and I strongly suspect also fiddling with the GHC source.
I'd like to know if it's feasible first.
Discussion period: a month?
More information about the Libraries