while -package:monad-loops
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.
IO lifted &&
IO lifted ||
Conditionally do the right action based on the truth value of the left
expression
unless the left side is true, perform the right action
unless the (monadic) left side is true, perform the right action
Bind the result of the last expression in an anaphoric when.
composition of >>= and >>?
composition of >>= and >>=?
Execute a monadic action so long as a monadic boolean returns true.
Keep checking an effectful condition while it holds.
Loop while we have an exception.