diff options
author | Joey Hess <joey@kitenet.net> | 2012-01-02 11:01:08 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-01-02 11:18:33 -0400 |
commit | 442202dd6d2ede66b35843f8e4708624041d25b0 (patch) | |
tree | 7ccb0200f1556c8465705b997e88ec05e8ca8818 /Utility | |
parent | 97d578915720554bbc1349a3f9deea66c6d413d3 (diff) |
add a new useful thing
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Monad.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Utility/Monad.hs b/Utility/Monad.hs index 0d1675fa4..9e2a16e8c 100644 --- a/Utility/Monad.hs +++ b/Utility/Monad.hs @@ -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 |