Loops/While: Difference between revisions

m
(→‎{{header|Haskell}}: add monadic implementation)
Line 207:
<lang haskell>import Control.Monad (when)
 
whileM :: (Monad m) => m Bool -> m ()a -> m ()
whileM cond body = do c <- cond
when c (body >> whileM cond body)</lang>
Anonymous user