IdrisDoc: Prelude.Applicative

Prelude.Applicative

when : Applicative f => Bool -> Lazy (f ()) -> f ()

Conditionally execute an applicative expression

liftA3 : Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d

Lift a three-argument function to an applicative

liftA2 : Applicative f => (a -> b -> c) -> f a -> f b -> f c

Lift a two-argument function to an applicative

liftA : Applicative f => (a -> b) -> f a -> f b

Lift a function to an applicative

guard : Alternative f => Bool -> f ()

guard a is pure () if a is True and empty if a is False

choiceMap : Foldable t => Alternative f => (a -> f b) -> t a -> f b

A fused version of choice and map.

choice : Foldable t => Alternative f => t (f a) -> f a

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.

interface Applicative 
pure : Applicative f => a -> f a
(<*>) : Applicative f => f (a -> b) -> f a -> f b
Fixity
Left associative, precedence 3
interface Alternative 
empty : Alternative f => f a
(<|>) : Alternative f => f a -> f a -> f a
Fixity
Left associative, precedence 2
(<*) : Applicative f => f a -> f b -> f a
Fixity
Left associative, precedence 3
(*>) : Applicative f => f a -> f b -> f b
Fixity
Left associative, precedence 3