add a new useful thing

This commit is contained in:
Joey Hess 2012-01-02 11:01:08 -04:00
parent 97d5789157
commit 442202dd6d

View file

@ -28,3 +28,11 @@ anyM p = liftM isJust . firstM p
{- Runs an action on values from a list until it succeeds. -}
untilTrue :: (Monad m) => [a] -> (a -> m Bool) -> m Bool
untilTrue = flip anyM
{- Runs a monadic action, passing its value to an observer
- before returning it. -}
observe :: (Monad m) => (a -> m b) -> m a -> m a
observe observer a = do
r <- a
_ <- observer r
return r