transformers-0.3.0.0: Concrete functor and monad transformers

Copyright | (c) Ross Paterson 2010
License | BSD-style (see the file LICENSE)
Maintainer | ross@soi.city.ac.uk
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell98

Control.Applicative.Lift

Contents

- Collecting errors

Description

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

Synopsis

- data Lift f a
  - = Pure a
  - | Other (f a)
- unLift :: Applicative f => Lift f a -> f a
- type Errors e = Lift (Constant e)
- failure :: Monoid e => e -> Errors e a

# Documentation

data Lift f a

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

Constructors

Pure a |
Other (f a) |

Instances

Alternative f => Alternative (Lift f) | A combination is `Pure` only either part is.
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) |

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

Projection to the other functor.

# Collecting errors

type Errors e = Lift (Constant e)

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 `ErrorT` from Control.Monad.Trans.Error, these computations continue after an error, collecting all the errors.

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

Report an error.