Skip to content

Commit

Permalink
Merge pull request #13 from haskell-works/newhoggy/new-whileM-and-unl…
Browse files Browse the repository at this point in the history
…essM-functions

New `whileM` and `unlessM` functions
  • Loading branch information
newhoggy authored Jan 5, 2025
2 parents 0dccc02 + cf98dc7 commit 5f92251
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/HaskellWorks/Control/Monad.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
module HaskellWorks.Control.Monad
( repeatNUntilM_,
( whileM,
unlessM,

repeatNUntilM_,
repeatNWhileM_,
) where

import HaskellWorks.Prelude

whileM :: Monad m => m Bool -> m ()
whileM act = do
b <- act
when b $ whileM act

unlessM :: Monad m => m Bool -> m ()
unlessM act = do
b <- act
unless b $ unlessM act

-- | Repeat an action n times until the action returns True.
repeatNUntilM_ :: ()
=> Monad m
Expand Down

0 comments on commit 5f92251

Please sign in to comment.