arrows-0.4.4.2: Arrow classes and transformers

Copyright | (c) Ross Paterson 2003
License | BSD-style (see the LICENSE file in the distribution)
Maintainer | R.Paterson@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

Instances details

ArrowError ex a => ArrowError ex (ReaderArrow r a) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods raise :: ReaderArrow r a ex b Source # handle :: ReaderArrow r a e b -> ReaderArrow r a (e, ex) b -> ReaderArrow r a e b Source # tryInUnless :: ReaderArrow r a e b -> ReaderArrow r a (e, b) c -> ReaderArrow r a (e, ex) c -> ReaderArrow r a e c Source # newError :: ReaderArrow r a e b -> ReaderArrow r a e (Either ex b) Source #
ArrowWriter s a => ArrowWriter s (ReaderArrow r a) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods write :: ReaderArrow r a s () Source # newWriter :: ReaderArrow r a e b -> ReaderArrow r a e (b, s) Source #
ArrowState s a => ArrowState s (ReaderArrow r a) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods fetch :: ReaderArrow r a e s Source # store :: ReaderArrow r a s () Source #
Arrow a => ArrowReader r (ReaderArrow r a) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods readState :: ReaderArrow r a b r Source # newReader :: ReaderArrow r a e b -> ReaderArrow r a (e, r) b Source #
Arrow a => ArrowAddReader r (ReaderArrow r a) a Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods liftReader :: a e b -> ReaderArrow r a e b Source # elimReader :: ReaderArrow r a e b -> a (e, r) b Source #
ArrowAddError ex a a' => ArrowAddError ex (ReaderArrow r a) (ReaderArrow r a') Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods liftError :: ReaderArrow r a' e b -> ReaderArrow r a e b Source # elimError :: ReaderArrow r a e b -> ReaderArrow r a' (e, ex) b -> ReaderArrow r a' e b Source #
ArrowAddWriter s a a' => ArrowAddWriter s (ReaderArrow r a) (ReaderArrow r a') Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods liftWriter :: ReaderArrow r a' e b -> ReaderArrow r a e b Source # elimWriter :: ReaderArrow r a e b -> ReaderArrow r a' e (b, s) Source #
ArrowAddState s a a' => ArrowAddState s (ReaderArrow r a) (ReaderArrow r a') Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods liftState :: ReaderArrow r a' e b -> ReaderArrow r a e b Source # elimState :: ReaderArrow r a e b -> ReaderArrow r a' (e, s) (b, s) Source #
Arrow a => ArrowTransformer (ReaderArrow r) a Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods lift :: a b c -> ReaderArrow r a b c Source #
Arrow a => Category (ReaderArrow r a :: Type -> Type -> Type) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods id :: forall (a0 :: k). ReaderArrow r a a0 a0 (.) :: forall (b :: k) (c :: k) (a0 :: k). ReaderArrow r a b c -> ReaderArrow r a a0 b -> ReaderArrow r a a0 c
Arrow a => Arrow (ReaderArrow r a) Source # |

Instance details

Defined in Control.Arrow.Transformer.Reader

Methods

arr :: (b -> c) -> ReaderArrow r a b c

first :: ReaderArrow r a b c -> ReaderArrow r a (b, d) (c, d)

second :: ReaderArrow r a b c -> ReaderArrow r a (d, b) (d, c)

(***) :: ReaderArrow r a b c -> ReaderArrow r a b' c' -> ReaderArrow r a (b, b') (c, c')

(&&&) :: ReaderArrow r a b c -> ReaderArrow r a b c' -> ReaderArrow r a b (c, c')

ArrowApply a => ArrowApply (ReaderArrow r a) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods app :: ReaderArrow r a (ReaderArrow r a b c, b) c
ArrowChoice a => ArrowChoice (ReaderArrow r a) Source # |

Instance details

Defined in Control.Arrow.Transformer.Reader

Methods

left :: ReaderArrow r a b c -> ReaderArrow r a (Either b d) (Either c d)

right :: ReaderArrow r a b c -> ReaderArrow r a (Either d b) (Either d c)

(+++) :: ReaderArrow r a b c -> ReaderArrow r a b' c' -> ReaderArrow r a (Either b b') (Either c c')

(|||) :: ReaderArrow r a b d -> ReaderArrow r a c d -> ReaderArrow r a (Either b c) d

ArrowLoop a => ArrowLoop (ReaderArrow r a) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods loop :: ReaderArrow r a (b, d) (c, d) -> ReaderArrow r a b c
ArrowPlus a => ArrowPlus (ReaderArrow r a) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods (<+>) :: ReaderArrow r a b c -> ReaderArrow r a b c -> ReaderArrow r a b c
ArrowZero a => ArrowZero (ReaderArrow r a) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods zeroArrow :: ReaderArrow r a b c
ArrowCircuit a => ArrowCircuit (ReaderArrow r a) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods delay :: b -> ReaderArrow r a b b Source #
Arrow a => Functor (ReaderArrow r a b) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods fmap :: (a0 -> b0) -> ReaderArrow r a b a0 -> ReaderArrow r a b b0 (<$) :: a0 -> ReaderArrow r a b b0 -> ReaderArrow r a b a0
Arrow a => Applicative (ReaderArrow r a b) Source # |

Instance details

Defined in Control.Arrow.Transformer.Reader

Methods

pure :: a0 -> ReaderArrow r a b a0

(<*>) :: ReaderArrow r a b (a0 -> b0) -> ReaderArrow r a b a0 -> ReaderArrow r a b b0

liftA2 :: (a0 -> b0 -> c) -> ReaderArrow r a b a0 -> ReaderArrow r a b b0 -> ReaderArrow r a b c

(*>) :: ReaderArrow r a b a0 -> ReaderArrow r a b b0 -> ReaderArrow r a b b0

(<*) :: ReaderArrow r a b a0 -> ReaderArrow r a b b0 -> ReaderArrow r a b a0

ArrowPlus a => Alternative (ReaderArrow r a b) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods empty :: ReaderArrow r a b a0 (<|>) :: ReaderArrow r a b a0 -> ReaderArrow r a b a0 -> ReaderArrow r a b a0 some :: ReaderArrow r a b a0 -> ReaderArrow r a b [a0] many :: ReaderArrow r a b a0 -> ReaderArrow r a b [a0]
ArrowPlus a => Semigroup (ReaderArrow r a b c) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods (<>) :: ReaderArrow r a b c -> ReaderArrow r a b c -> ReaderArrow r a b c sconcat :: NonEmpty (ReaderArrow r a b c) -> ReaderArrow r a b c stimes :: Integral b0 => b0 -> ReaderArrow r a b c -> ReaderArrow r a b c
ArrowPlus a => Monoid (ReaderArrow r a b c) Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods mempty :: ReaderArrow r a b c mappend :: ReaderArrow r a b c -> ReaderArrow r a b c -> ReaderArrow r a b c mconcat :: [ReaderArrow r a b c] -> ReaderArrow r a b c

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

Instances details

ArrowAddReader r a a' => ArrowAddReader r (Automaton a) (Automaton a') Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods liftReader :: Automaton a' e b -> Automaton a e b Source # elimReader :: Automaton a e b -> Automaton a' (e, r) b Source #
Arrow a => ArrowAddReader r (ReaderArrow r a) a Source # |
Instance details Defined in Control.Arrow.Transformer.Reader Methods liftReader :: a e b -> ReaderArrow r a e b Source # elimReader :: ReaderArrow r a e b -> a (e, r) b Source #
(ArrowAddReader r a a', ArrowChoice a, ArrowChoice a') => ArrowAddReader r (ErrorArrow ex a) (ErrorArrow ex a') Source # |
Instance details Defined in Control.Arrow.Transformer.Error Methods liftReader :: ErrorArrow ex a' e b -> ErrorArrow ex a e b Source # elimReader :: ErrorArrow ex a e b -> ErrorArrow ex a' (e, r) b Source #
ArrowAddReader r a a' => ArrowAddReader r (StateArrow s a) (StateArrow s a') Source # |
Instance details Defined in Control.Arrow.Transformer.State Methods liftReader :: StateArrow s a' e b -> StateArrow s a e b Source # elimReader :: StateArrow s a e b -> StateArrow s a' (e, r) b Source #
(ArrowAddReader r a a', Applicative f) => ArrowAddReader r (StaticArrow f a) (StaticArrow f a') Source # |
Instance details Defined in Control.Arrow.Transformer.Static Methods liftReader :: StaticArrow f a' e b -> StaticArrow f a e b Source # elimReader :: StaticArrow f a e b -> StaticArrow f a' (e, r) b Source #
(ArrowAddReader r a a', Monoid w) => ArrowAddReader r (WriterArrow w a) (WriterArrow w a') Source # |
Instance details Defined in Control.Arrow.Transformer.Writer Methods liftReader :: WriterArrow w a' e b -> WriterArrow w a e b Source # elimReader :: WriterArrow w a e b -> WriterArrow w a' (e, r) b Source #