Control.Monad.Loops
- Package
- purescript-monad-loops
- Repository
- mlang/purescript-monad-loops
#whileM' Source
whileM' :: forall a f m. Monad m => Applicative f => Monoid (f a) => m Boolean -> m a -> m (f a)
Execute an action repeatedly as long as the given boolean expression
returns true
. The condition is evaluated before the loop body.
Collects the results into an arbitrary Applicative
monoidal structure.
#untilM' Source
untilM' :: forall a f m. Monad m => Applicative f => Monoid (f a) => m a -> m Boolean -> m (f a)
Execute an action repeatedly until the condition expression returns true
.
The condition is evaluated after the loop body.
Collects results into an arbitrary Applicative
monoidal structure.
For an Applicative
semigroupoid result, see
Control.Monad.Rec.Loops.untilM'
.
#iterateWhile Source
iterateWhile :: forall m a. Monad m => (a -> Boolean) -> m a -> m a
Execute an action repeatedly until its result fails to satisfy a predicate, and return that result (discarding all others).
#iterateUntil Source
iterateUntil :: forall m a. Monad m => (a -> Boolean) -> m a -> m a
Execute an action repeatedly until its result satisfies a predicate, and return that result (discarding all others).
#iterateUntilM Source
iterateUntilM :: forall a m. Monad m => (a -> Boolean) -> (a -> m a) -> a -> m a
Yields the result of applying f
until p
holds.
#whileJust' Source
whileJust' :: forall b f a m. Monad m => Applicative f => Monoid (f b) => m (Maybe a) -> (a -> m b) -> m (f b)
As long as the supplied Maybe
expression returns Just
, the loop
body will be called and passed the value contained in the Just
.
Results are collected into an arbitrary Applicative
monoidal structure.
#whileJust_ Source
whileJust_ :: forall m b a. Monad m => m (Maybe a) -> (a -> m b) -> m Unit
As long as the supplied "Maybe" expression returns "Just _", the loop body will be called and passed the value contained in the 'Just'. Results are discarded.
#unfoldM' Source
unfoldM' :: forall a f m. Monad m => Applicative f => Monoid (f a) => m (Maybe a) -> m (f a)
The supplied Maybe
expression will be repeatedly called until it
returns Nothing
.
All Just
values are collected into an Applicative
monoidal structure.