Skip to content
Snippets Groups Projects
Commit f192a2b4 authored by Jens Nolte's avatar Jens Nolte
Browse files

Add whenM/unlessM

parent b1bd5497
No related branches found
No related tags found
No related merge requests found
Pipeline #2559 passed
......@@ -117,3 +117,15 @@ splitOn p s = case break p s of
sleepForever :: MonadIO m => m a
sleepForever = liftIO $ forever $ threadDelay 1000000000000
-- | Monadic version of @when@, taking the condition in the monad
whenM :: Monad m => m Bool -> m () -> m ()
whenM mb action = do
b <- mb
when b action
-- | Monadic version of @unless@, taking the condition in the monad
unlessM :: Monad m => m Bool -> m () -> m ()
unlessM condM acc = do
cond <- condM
unless cond acc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment