IdrisDoc: Prelude.Applicative

Prelude.Applicative

(*>) : Applicative f => f a -> f b -> f b
Fixity
Left associative, precedence 3
(<*) : Applicative f => f a -> f b -> f a
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
interface Applicative 
pure : Applicative f => a -> f a
(<*>) : Applicative f => f (a -> b) -> f a -> f b
Fixity
Left associative, precedence 3
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.

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

A fused version of choice and map.

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

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

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

Lift a function to an applicative

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

Lift a two-argument function to an applicative

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

Lift a three-argument function to an applicative

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

Conditionally execute an applicative expression