
8 May
2009
8 May
'09
5:57 a.m.
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]