Module

Control.Monad.Loops

#whileM

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

#whileM_

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

#untilM_

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

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

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

Yields the result of applying f until p holds.

#whileJust

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

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

#untilJust

untilJust :: forall a m. Monad 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. Monad 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 m f a. 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.

#unfoldM_

unfoldM_ :: forall a m. Monad 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. Monad m => (a -> m (Maybe (Tuple b a))) -> a -> m (Array b)

#unfoldrM'

unfoldrM' :: forall a b f m. Monad 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. Monad m => List (m Boolean) -> m Boolean

short-circuit 'and' for monadic boolean values.

#orM

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

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

#anyPM

anyPM :: forall m a. Monad 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 m a. Monad 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. Monad m => (a -> m Boolean) -> List a -> m Boolean

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

#allM

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

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

Modules