Conditionally execute an applicative expression
Lift a three-argument function to an applicative
Lift a two-argument function to an applicative
Lift a function to an applicative
guard a
is pure ()
if a
is True
and empty
if a
is False
A fused version of choice and map.
Fold using Alternative
If you have a left-biased alternative operator <|>
, then choice
performs left-biased choice from a list of alternatives, which means that
it evaluates to the left-most non-empty
alternative.
If the list is empty, or all values in it are empty
, then it
evaluates to empty
.
Example:
-- given a parser expression like:
expr = literal <|> keyword <|> funcall
-- choice lets you write this as:
expr = choice [literal, keyword, funcall]
Note: In Haskell, choice
is called asum
.