module HyLo.Util ( sequenceUntil )

where

sequenceUntil :: Monad m => (a -> Bool) -> [m a] -> m [a]
sequenceUntil _ [] = return []
sequenceUntil p (m:ms) = do a <- m
                            if p a
                              then return [a]
                              else do as <- sequenceUntil p ms
                                      return (a:as)