Module

Control.Monad.Rec.Loops

#whileM

whileM :: forall a m. MonadRec m => m Boolean -> m a -> m (Array 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 Array. See whileM' for a generalized Applicative monoidal result.

#whileM'

whileM' :: forall a f m. 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.

#whileM_

whileM_ :: forall a m. MonadRec m => m Boolean -> m a -> m Unit

Execute an action repeatedly as long as the given boolean expression returns true. The condition is evaluated before the loop body. Ignores the results of loop body execution.

#untilM

untilM :: forall a m. MonadRec m => m a -> m Boolean -> m (Array a)

Execute an action repeatedly until the condition expression returns true. The condition is evaluated after the loop body. Collects results into an Array.

#untilM'

untilM' :: forall a f m. 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.

#untilM_

untilM_ :: forall a m. MonadRec m => m a -> m Boolean -> m Unit

Execute an action repeatedly until the condition expression returns true. The condition is evaluated after the loop body. Ignores the results of loop body execution.

#iterateWhile

iterateWhile :: forall a m. 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

iterateUntil :: forall a m. 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

iterateUntilM :: forall a m. MonadRec m => (a -> Boolean) -> (a -> m a) -> a -> m a

Yields the result of applying f until p holds.

#whileJust

whileJust :: forall a b m. MonadRec m => m (Maybe a) -> (a -> m b) -> m (Array 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 array.

#whileJust'

whileJust' :: forall a b f m. 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_

whileJust_ :: forall a b m. 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.

#untilJust

untilJust :: forall a m. MonadRec m => m (Maybe a) -> m a

Run the supplied "Maybe" computation repeatedly until it returns a value. Returns that value.

#unfoldM

unfoldM :: forall a m. MonadRec m => m (Maybe a) -> m (Array a)

The supplied Maybe expression will be repeatedly called until it returns Nothing. All values returned are collected into an array.

#unfoldM'

unfoldM' :: forall a f m. 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.

#unfoldM_

unfoldM_ :: forall a m. MonadRec m => m (Maybe a) -> m Unit

The supplied Maybe expression will be repeatedly called until it returns Nothing. All values returned are discarded.

#unfoldrM

unfoldrM :: forall a b m. MonadRec m => (a -> m (Maybe (Tuple b a))) -> a -> m (Array b)

#unfoldrM'

unfoldrM' :: forall a b f m. MonadRec m => Applicative f => Monoid (f b) => (a -> m (Maybe (Tuple b a))) -> a -> m (f b)

See 'Data.List.unfoldr'. This is a monad-friendly version of that, with a twist. Rather than returning a list, it returns any MonadPlus type of your choice.

#andM

andM :: forall m. MonadRec m => List (m Boolean) -> m Boolean

short-circuit 'and' for monadic boolean values.

#orM

orM :: forall m. MonadRec m => List (m Boolean) -> m Boolean

short-circuit 'or' for values of type Monad m => m Bool

#anyPM

anyPM :: forall m a. MonadRec m => List (a -> m Boolean) -> (a -> m Boolean)

short-circuit 'any' with a list of "monadic predicates". Tests the value presented against each predicate in turn until one passes, then returns True without any further processing. If none passes, returns False.

#allPM

allPM :: forall a m. MonadRec m => List (a -> m Boolean) -> (a -> m Boolean)

short-circuit 'all' with a list of "monadic predicates". Tests the value presented against each predicate in turn until one fails, then returns False. if none fail, returns True.

#anyM

anyM :: forall a m. MonadRec m => (a -> m Boolean) -> List a -> m Boolean

short-circuit 'any' with a "monadic predicate".

#allM

allM :: forall m a. MonadRec m => (a -> m Boolean) -> List a -> m Boolean

short-circuit 'all' with a "monadic predicate".

Modules