Control.Monad.Rec.Loops
- Package
- purescript-monad-loops
- Repository
- mlang/purescript-monad-loops
#whileM' Source
whileM' :: forall m f a. MonadRec 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 m f a. MonadRec m => Applicative f => Semigroup (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
semigroupoid structure.
#iterateWhile Source
iterateWhile :: forall m a. MonadRec 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. MonadRec 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 m a. MonadRec m => (a -> Boolean) -> (a -> m a) -> a -> m a
Yields the result of applying f until p holds.
#whileJust' Source
whileJust' :: forall m f b a. MonadRec 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 MonadPlus container.
#whileJust_ Source
whileJust_ :: forall m b a. MonadRec 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 m f a. MonadRec 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 values returned are collected into an Applicative Monoid.