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-Inferred |
Language | Haskell98 |
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
- class (ArrowState s a, Arrow a') => ArrowAddState s a a' | a -> a' where
- 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
- class (ArrowWriter w a, Arrow a') => ArrowAddWriter w a a' | a -> a' where
- liftWriter :: a' e b -> a e b
- elimWriter :: a e b -> a' e (b, w)
- class (ArrowError ex a, Arrow a') => ArrowAddError ex a a' | a -> a' where
- class (ArrowCircuit a, Arrow a') => ArrowAddStream a a' | a -> a' where
- liftStream :: a' e b -> a e b
- elimStream :: a (e, b) c -> a' (e, Stream b) (Stream c)
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
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
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
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
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
(ArrowLoop a, ArrowApply a) => ArrowAddStream (Automaton a) a Source # | |
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 # | |
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 # | |
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 # |