arrows-0.4.4.1: Arrow classes and transformers

Copyright | (c) Ross Paterson 2003
License | BSD-style (see the LICENSE file in the distribution)
Maintainer | ross@soi.city.ac.uk
Stability | experimental
Portability | non-portable (multi-parameter type classes)
Safe Haskell | Safe
Language | Haskell98

Control.Arrow.Transformer.Reader

Description

Arrow transformer that adds a read-only state (i.e. an environment).

Synopsis

- newtype ReaderArrow r a b c = ReaderArrow (a (b, r) c)
- runReader :: Arrow a => ReaderArrow r a e b -> a (e, r) b
- class (ArrowReader r a, Arrow a') => ArrowAddReader r a a' | a -> a' where
  - liftReader :: a' e b -> a e b
  - elimReader :: a e b -> a' (e, r) b

# Documentation

newtype ReaderArrow r a b c Source

An arrow type that augments an existing arrow with a read-only state (or environment). The `ArrowReader` class contains the operations on this state.

Constructors

ReaderArrow (a (b, r) c) |

Instances

Arrow a => Category * (ReaderArrow r a) Source |
ArrowError ex a => ArrowError ex (ReaderArrow r a) Source |
ArrowWriter s a => ArrowWriter s (ReaderArrow r a) Source |
ArrowState s a => ArrowState s (ReaderArrow r a) Source |
Arrow a => ArrowReader r (ReaderArrow r a) Source |
Arrow a => ArrowAddReader r (ReaderArrow r a) a Source |
ArrowAddError ex a a' => ArrowAddError ex (ReaderArrow r a) (ReaderArrow r a') Source |
ArrowAddWriter s a a' => ArrowAddWriter s (ReaderArrow r a) (ReaderArrow r a') Source |
ArrowAddState s a a' => ArrowAddState s (ReaderArrow r a) (ReaderArrow r a') Source |
Arrow a => ArrowTransformer (ReaderArrow r) a Source |
Arrow a => Arrow (ReaderArrow r a) Source |
ArrowZero a => ArrowZero (ReaderArrow r a) Source |
ArrowPlus a => ArrowPlus (ReaderArrow r a) Source |
ArrowChoice a => ArrowChoice (ReaderArrow r a) Source |
ArrowApply a => ArrowApply (ReaderArrow r a) Source |
ArrowLoop a => ArrowLoop (ReaderArrow r a) Source |
ArrowCircuit a => ArrowCircuit (ReaderArrow r a) Source |
Arrow a => Functor (ReaderArrow r a b) Source |
Arrow a => Applicative (ReaderArrow r a b) Source |
ArrowPlus a => Alternative (ReaderArrow r a b) Source |
ArrowPlus a => Monoid (ReaderArrow r a b c) Source |

runReader :: Arrow a => ReaderArrow r a e b -> a (e, r) b Source

Encapsulation of a state-reading computation, taking a value for the state.

Typical usage in arrow notation:

    	proc p -> ...
    		(|runReader cmd|) env

class (ArrowReader r a, Arrow a') => ArrowAddReader r a a' | a -> a' where Source

Adding a `ReaderArrow` to an arrow type, but not necessarily as the outer arrow transformer.

Typically a composite arrow type is built by applying a series of arrow transformer to a base arrow (usually either a function arrow or a `Kleisli` arrow. One can add a transformer to the top of this stack using the `lift` method of the `ArrowTransformer` class, or remove a state transformer from the top of the stack using the `runReader` encapsulation operator. The methods of this class add and remove state transformers anywhere in the stack. In the instance

    	instance Arrow a => ArrowAddReader r (ArrowReader r a) a

they are equivalent to `lift` and `runReader` respectively. Instances are lifted through other transformers with

    	instance ArrowAddReader r a a' =>
    		ArrowAddReader r (FooArrow a) (FooArrow a')

Methods

liftReader :: a' e b -> a e b Source

Lift a computation from an arrow to one with an added environment.

Typical usage in arrow notation:

    	proc p -> ...
    		(|liftReader cmd|)

elimReader :: a e b -> a' (e, r) b Source

Elimination of a state reader from a computation, taking a value for the state.

Typical usage in arrow notation:

    	proc p -> ...
    		(|elimReader cmd|) env

Instances

ArrowAddReader r a a' => ArrowAddReader r (Automaton a) (Automaton a') Source |
Arrow a => ArrowAddReader r (ReaderArrow r a) a Source |
(ArrowAddReader r a a', ArrowChoice a, ArrowChoice a') => ArrowAddReader r (ErrorArrow ex a) (ErrorArrow ex a') Source |
ArrowAddReader r a a' => ArrowAddReader r (StateArrow s a) (StateArrow s a') Source |
(ArrowAddReader r a a', Applicative f) => ArrowAddReader r (StaticArrow f a) (StaticArrow f a') Source |
(ArrowAddReader r a a', Monoid w) => ArrowAddReader r (WriterArrow w a) (WriterArrow w a') Source |