# Control.Applicative.Lift

#### Description

Adding a new kind of pure computation to an applicative functor.

## Lifting an applicative

data Lift f a Source

Applicative functor formed by adding pure computations to a given applicative functor.

#### Constructors

 Pure a Other (f a)

#### Instances

 Functor f => Functor (Lift f) Applicative f => Applicative (Lift f) A combination is `Pure` only if both parts are. Foldable f => Foldable (Lift f) Traversable f => Traversable (Lift f) Alternative f => Alternative (Lift f) A combination is `Pure` only either part is. Show1 f => Show1 (Lift f) Read1 f => Read1 (Lift f) Ord1 f => Ord1 (Lift f) Eq1 f => Eq1 (Lift f) (Eq1 f, Eq a) => Eq (Lift f a) (Ord1 f, Ord a) => Ord (Lift f a) (Read1 f, Read a) => Read (Lift f a) (Show1 f, Show a) => Show (Lift f a)

unLift :: Applicative f => Lift f a -> f a Source

Projection to the other functor.

mapLift :: (f a -> g a) -> Lift f a -> Lift g a Source

Apply a transformation to the other computation.

## Collecting errors

type Errors e = Lift (Constant e) Source

An applicative functor that collects a monoid (e.g. lists) of errors. A sequence of computations fails if any of its components do, but unlike monads made with `ExceptT` from Control.Monad.Trans.Except, these computations continue after an error, collecting all the errors.

• ``pure` f `<*>` `pure` x = `pure` (f x)`
• ``pure` f `<*>` `failure` e = `failure` e`
• ``failure` e `<*>` `pure` x = `failure` e`
• ``failure` e1 `<*>` `failure` e2 = `failure` (e1 `<>` e2)`

runErrors :: Errors e a -> Either e a Source

Extractor for computations with accumulating errors.

• ``runErrors` (`pure` x) = `Right` x`
• ``runErrors` (`failure` e) = `Left` e`

failure :: Monoid e => e -> Errors e a Source

Report an error.

© The University of Glasgow and others