Proposal: Add sequenceWhile and SequenceWhile_ to Control.Monad
Dominic Steinitz
dominic at steinitz.org
Fri May 8 05:57:08 EDT 2009
I'm not sure of the protocol for adding things to existing libraries but I'd
like to propose the addition of these two functions to Control.Monad.
sequenceWhile_ :: Monad m => (a -> Bool) -> [m a] -> m ()
sequenceWhile_ _ [] =
return ()
sequenceWhile_ p (x:xs) =
x >>= \c -> if (p c) then sequenceWhile_ p xs else return ()
sequenceWhile :: Monad m => (a -> Bool) -> [m a] -> m [a]
sequenceWhile _ [] =
return []
sequenceWhile p (x:xs) = do
y <- x
if (p y)
then do
ys <- sequenceWhile p xs
return (y:ys)
else
return [y]
More information about the Libraries
mailing list