arrows-0.4.4.2: Arrow classes and transformers
Copyright(c) Ross Paterson 2003
LicenseBSD-style (see the LICENSE file in the distribution)
Maintainerross@soi.city.ac.uk
Stabilityexperimental
Portabilitynon-portable (multi-parameter type classes)
Safe HaskellSafe-Inferred
LanguageHaskell98

Control.Arrow.Internals

Description

Manipulation of composite arrow types, beyond the basic lifting and encapsulation provided with each arrow transformer.

The signatures are designed to be compatible with the proposed notation for arrows, cf. http://www.haskell.org/arrows/.

Synopsis

Documentation

class (ArrowState s a, Arrow a') => ArrowAddState s a a' | a -> a' where Source #

Adding a StateArrow 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 runState encapsulation operator. The methods of this class add and remove state transformers anywhere in the stack. In the instance

   instance Arrow a => ArrowAddState s (ArrowState s a) a

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

   instance ArrowAddState s a a' =>
       ArrowAddState s (FooArrow a) (FooArrow a')

Methods

liftState :: a' e b -> a e b Source #

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

Typical usage in arrow notation:

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

elimState :: a e b -> a' (e, s) (b, s) Source #

Elimination of a state transformer from a computation, exposing the initial and final states.

Typical usage in arrow notation:

   proc p -> do
       ...
       (result, final_state) <- (|elimState cmd|) init_state

Instances

Instances details
ArrowAddState r a a' => ArrowAddState r (Automaton a) (Automaton a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Automaton

Methods

liftState :: Automaton a' e b -> Automaton a e b Source #

elimState :: Automaton a e b -> Automaton a' (e, r) (b, r) Source #

Arrow a => ArrowAddState s (StateArrow s a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.State

Methods

liftState :: a e b -> StateArrow s a e b Source #

elimState :: StateArrow s a e b -> a (e, s) (b, s) Source #

(ArrowAddState s a a', ArrowChoice a, ArrowChoice a') => ArrowAddState s (ErrorArrow ex a) (ErrorArrow ex a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Error

Methods

liftState :: ErrorArrow ex a' e b -> ErrorArrow ex a e b Source #

elimState :: ErrorArrow ex a e b -> ErrorArrow ex a' (e, s) (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 #

(ArrowAddState s a a', Applicative f) => ArrowAddState s (StaticArrow f a) (StaticArrow f a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Static

Methods

liftState :: StaticArrow f a' e b -> StaticArrow f a e b Source #

elimState :: StaticArrow f a e b -> StaticArrow f a' (e, s) (b, s) Source #

(ArrowAddState s a a', Monoid w) => ArrowAddState s (WriterArrow w a) (WriterArrow w a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

liftState :: WriterArrow w a' e b -> WriterArrow w a e b Source #

elimState :: WriterArrow w a e b -> WriterArrow w a' (e, s) (b, s) Source #

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 #

class (ArrowWriter w a, Arrow a') => ArrowAddWriter w a a' | a -> a' where Source #

Adding a WriterArrow 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 runWriter encapsulation operator. The methods of this class add and remove state transformers anywhere in the stack. In the instance

   instance Arrow a => ArrowAddWriter w (ArrowWriter w a) a

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

   instance ArrowAddWriter w a a' =>
       ArrowAddWriter w (FooArrow a) (FooArrow a')

Methods

liftWriter :: a' e b -> a e b Source #

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

Typical usage in arrow notation:

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

elimWriter :: a e b -> a' e (b, w) Source #

Elimination of an output writer from a computation, providing the accumulated output.

Typical usage in arrow notation:

   proc p -> do
       ...
       (result, output) <- (|elimWriter cmd|)

Instances

Instances details
ArrowAddWriter w a a' => ArrowAddWriter w (Automaton a) (Automaton a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Automaton

Methods

liftWriter :: Automaton a' e b -> Automaton a e b Source #

elimWriter :: Automaton a e b -> Automaton a' e (b, w) Source #

(Arrow a, Monoid w) => ArrowAddWriter w (WriterArrow w a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

liftWriter :: a e b -> WriterArrow w a e b Source #

elimWriter :: WriterArrow w a e b -> a e (b, w) Source #

(ArrowAddWriter w a a', ArrowChoice a, ArrowChoice a') => ArrowAddWriter w (ErrorArrow ex a) (ErrorArrow ex a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Error

Methods

liftWriter :: ErrorArrow ex a' e b -> ErrorArrow ex a e b Source #

elimWriter :: ErrorArrow ex a e b -> ErrorArrow ex a' e (b, w) 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 #

ArrowAddWriter w a a' => ArrowAddWriter w (StateArrow s a) (StateArrow s a') Source # 
Instance details

Defined in Control.Arrow.Transformer.State

Methods

liftWriter :: StateArrow s a' e b -> StateArrow s a e b Source #

elimWriter :: StateArrow s a e b -> StateArrow s a' e (b, w) Source #

(ArrowAddWriter w a a', Applicative f) => ArrowAddWriter w (StaticArrow f a) (StaticArrow f a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Static

Methods

liftWriter :: StaticArrow f a' e b -> StaticArrow f a e b Source #

elimWriter :: StaticArrow f a e b -> StaticArrow f a' e (b, w) Source #

class (ArrowError ex a, Arrow a') => ArrowAddError ex a a' | a -> a' where Source #

Adding a ErrorArrow 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 runError encapsulation operator. The methods of this class add and remove state transformers anywhere in the stack. In the instance

   instance Arrow a => ArrowAddError ex (ArrowError ex a) a

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

   instance ArrowAddError ex a a' =>
       ArrowAddError ex (FooArrow a) (FooArrow a')

This could be combined with handle, since the resulting arrow is always the arrow of the handler. Separating them has the advantage of consistency with the other arrows, and might give more helpful type error messages.

Methods

liftError :: a' e b -> a e b Source #

Lift a computation from an arrow to one with error handling.

Typical usage in arrow notation:

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

elimError :: a e b -> a' (e, ex) b -> a' e b Source #

Elimination of errors from a computation, by completely handling any errors.

Typical usage in arrow notation:

   proc p -> ...
       body `elimError` \ex -> handler

Instances

Instances details
ArrowChoice a => ArrowAddError ex (ErrorArrow ex a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Error

Methods

liftError :: a e b -> ErrorArrow ex a e b Source #

elimError :: ErrorArrow ex a e b -> a (e, ex) b -> a e 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 #

ArrowAddError ex a a' => ArrowAddError ex (StateArrow s a) (StateArrow s a') Source # 
Instance details

Defined in Control.Arrow.Transformer.State

Methods

liftError :: StateArrow s a' e b -> StateArrow s a e b Source #

elimError :: StateArrow s a e b -> StateArrow s a' (e, ex) b -> StateArrow s a' e b Source #

(ArrowAddError ex a a', Applicative f) => ArrowAddError ex (StaticArrow f a) (StaticArrow f a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Static

Methods

liftError :: StaticArrow f a' e b -> StaticArrow f a e b Source #

elimError :: StaticArrow f a e b -> StaticArrow f a' (e, ex) b -> StaticArrow f a' e b Source #

(ArrowAddError ex a a', Monoid w) => ArrowAddError ex (WriterArrow w a) (WriterArrow w a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

liftError :: WriterArrow w a' e b -> WriterArrow w a e b Source #

elimError :: WriterArrow w a e b -> WriterArrow w a' (e, ex) b -> WriterArrow w a' e b Source #

class (ArrowCircuit a, Arrow a') => ArrowAddStream a a' | a -> a' where Source #

Adding a StreamArrow 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 runStream encapsulation operator. The methods of this class add and remove state transformers anywhere in the stack. In the instance

   instance Arrow a => ArrowAddStream (ArrowStream a) a

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

   instance ArrowAddStream a a' =>
       ArrowAddStream (FooArrow a) (FooArrow a')

Methods

liftStream :: a' e b -> a e b Source #

Lift a computation from an arrow to a stream processing one.

Typical usage in arrow notation:

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

elimStream :: a (e, b) c -> a' (e, Stream b) (Stream c) Source #

Run a stream processor on a stream of inputs, obtaining a stream of outputs.

Typical usage in arrow notation:

   proc p -> do
       ...
       ys <- (|elimStream (\x -> ...)|) xs

Here xs refers to the input stream and x to individual elements of that stream. ys is bound to the output stream.

Instances

Instances details
(ArrowLoop a, ArrowApply a) => ArrowAddStream (Automaton a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Automaton

Methods

liftStream :: a e b -> Automaton a e b Source #

elimStream :: Automaton a (e, b) c -> a (e, Stream b) (Stream c) Source #

ArrowLoop a => ArrowAddStream (StreamArrow a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Stream

Methods

liftStream :: a e b -> StreamArrow a e b Source #

elimStream :: StreamArrow a (e, b) c -> a (e, Stream b) (Stream c) Source #

(ArrowAddStream a a', Applicative f) => ArrowAddStream (StaticArrow f a) (StaticArrow f a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Static

Methods

liftStream :: StaticArrow f a' e b -> StaticArrow f a e b Source #

elimStream :: StaticArrow f a (e, b) c -> StaticArrow f a' (e, Stream b) (Stream c) Source #