[Proposal] Move most of Control.Monad to Control.Applicative

Thomas Davie tom.davie at gmail.com
Fri Jan 30 11:03:29 EST 2009


Hi,
   Most of Control.Monad doesn't actually rely on Monads, but instead  
Applicatives.  Data.Traversable fixes this in a lot of cases, but it  
would be nice to have the 'standard' functions as general as possible.

My quick reading of Control.Monad says these at least should fall  
victim to demotion to applicatives:

mapA :: (Applicative f) => (a -> f b) -> [a] -> f [b]
mapA_ :: (Applicative f) => (a -> f b) -> [a] -> f ()
sequence :: (Applicative f) => [f a] -> f [a]
sequence_ :: (Applicative f) => [f a] -> f ()

filterA :: (Applicative f) => (a -> f Bool) -> [a] -> f [a]
mapAndUnzipA :: (Applicative f) => (a -> f (b,c)) -> [a] -> f ([b], [c])
zipWithA :: (Applicative f) => (a -> b -> f c) -> [a] -> [b] -> f [c]
zipWithA_ :: (Applicative f) => (a -> b -> f c) -> [a] -> [b] -> f ()
replicateA :: (Applicative f) => Int -> f a -> f [a]
replicateA_ :: (Applicative f) => Int -> f a -> f ()

when :: (Applicative f) => Bool -> f () -> f ()
unless :: (Applicative f) => Bool -> f () -> f ()

I may have missed some.

Bob


More information about the Haskell-prime mailing list