while
A binary pattern is used to conditionally apply a function to a source
pattern. The function is applied when a True value is active,
and the pattern is let through unchanged when a False value
is active. No events are let through where no binary values are
active.
A while loop, run the second argument while the first argument is
true. The action is run in a
scope. See also
loop.
x <- mutable_ x
while (x %< 10) $ do
x @= x + 1
A while loop:
While name invariant measure condition body.
The string
name is merely for diagnostic purposes. If the
measure is
Nothing, then only partial correctness of this loop
will be proven.
The while statement executes an expression and a statement
repeatedly until the value of the expression is false.
Run the given parser while the given character predicate succeeds.
Keep running an operation until it becomes a
Nothing,
accumulating the monoid results inside the
Justs as the result
of the overall loop.
Keep running an operation until it becomes
False. As an
example:
whileM $ do sleep 0.1; notM $ doesFileExist "foo.txt"
readFile "foo.txt"
If you need some state persisted between each test, use
loopM.
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 a list.
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.
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.
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 a list.
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
MonadPlus value.