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

_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime

Reply via email to