arrows-0.4.4.2: Arrow classes and transformers

Copyright(c) Ross Paterson 2003
LicenseBSD-style (see the LICENSE file in the distribution)
MaintainerR.Paterson@city.ac.uk
Stabilityexperimental
Portabilitynon-portable (multi-parameter type classes)
Safe HaskellSafe
LanguageHaskell98

Control.Arrow.Transformer.Reader

Description

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

Synopsis

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

ArrowError ex a => ArrowError ex (ReaderArrow r a) Source # 

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 # 

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 # 

Methods

fetch :: ReaderArrow r a e s Source #

store :: ReaderArrow r a s () Source #

Arrow a => ArrowReader r (ReaderArrow r a) Source # 

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 # 

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 # 

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 # 

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 # 

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 # 

Methods

lift :: a b c -> ReaderArrow r a b c Source #

Arrow a => Category * (ReaderArrow r a) Source # 

Methods

id :: cat a a #

(.) :: cat b c -> cat a b -> cat a c #

Arrow a => Arrow (ReaderArrow r a) Source # 

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') #

ArrowZero a => ArrowZero (ReaderArrow r a) Source # 

Methods

zeroArrow :: ReaderArrow r a b c #

ArrowPlus a => ArrowPlus (ReaderArrow r a) Source # 

Methods

(<+>) :: ReaderArrow r a b c -> ReaderArrow r a b c -> ReaderArrow r a b c #

ArrowChoice a => ArrowChoice (ReaderArrow r a) Source # 

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 #

ArrowApply a => ArrowApply (ReaderArrow r a) Source # 

Methods

app :: ReaderArrow r a (ReaderArrow r a b c, b) c #

ArrowLoop a => ArrowLoop (ReaderArrow r a) Source # 

Methods

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

ArrowCircuit a => ArrowCircuit (ReaderArrow r a) Source # 

Methods

delay :: b -> ReaderArrow r a b b Source #

Arrow a => Functor (ReaderArrow r a b) Source # 

Methods

fmap :: (a -> b) -> ReaderArrow r a b a -> ReaderArrow r a b b #

(<$) :: a -> ReaderArrow r a b b -> ReaderArrow r a b a #

Arrow a => Applicative (ReaderArrow r a b) Source # 

Methods

pure :: a -> ReaderArrow r a b a #

(<*>) :: ReaderArrow r a b (a -> b) -> ReaderArrow r a b a -> ReaderArrow r a b b #

liftA2 :: (a -> b -> c) -> ReaderArrow r a b a -> ReaderArrow r a b b -> ReaderArrow r a b c #

(*>) :: ReaderArrow r a b a -> ReaderArrow r a b b -> ReaderArrow r a b b #

(<*) :: ReaderArrow r a b a -> ReaderArrow r a b b -> ReaderArrow r a b a #

ArrowPlus a => Alternative (ReaderArrow r a b) Source # 

Methods

empty :: ReaderArrow r a b a #

(<|>) :: ReaderArrow r a b a -> ReaderArrow r a b a -> ReaderArrow r a b a #

some :: ReaderArrow r a b a -> ReaderArrow r a b [a] #

many :: ReaderArrow r a b a -> ReaderArrow r a b [a] #

ArrowPlus a => Semigroup (ReaderArrow r a b c) Source # 

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 b => b -> ReaderArrow r a b c -> ReaderArrow r a b c #

ArrowPlus a => Monoid (ReaderArrow r a b c) Source # 

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')

Minimal complete definition

liftReader, elimReader

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 # 

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 # 

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 # 

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 # 

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 # 

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 # 

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 #