|
Control.Arrow.Operations | Portability | non-portable (multi-parameter type classes) | Stability | experimental | Maintainer | ross@soi.city.ac.uk |
|
|
|
|
|
Description |
Subclasses of Arrow providing additional operations.
The signatures are designed to be compatible with the proposed
notation for arrows, cf. http://www.haskell.org/arrows/.
|
|
Synopsis |
|
|
|
|
Conventions
|
|
The arrow classes defined in this module have names like ArrowFoo,
and contain operations specific to such arrows. Some of these include
a method newFoo, which maps computations to computations of the
same arrow type, but exposing some of the internals of the arrow.
Arrow transformers have names like BarArrow, and are
instances of appropriate arrow classes. For each arrow
transformer, there is typically an encapsulation operator
runBar that removes that transformer from the outside of an
arrow type. The Control.Arrow.Transformer.lift method of the
Control.Arrow.Transformer.ArrowTransformer class adds an arrow
transformer to the outside of an arrow type.
Typically a composite arrow type is built by applying a series of arrow
transformers to a base arrow (usually either a function arrow or a
Kleisli arrow. The Control.Arrow.Transformer.lift method and the
runBar function operate only on the arrow transformer at the top
of this stack. For more sophisticated manipulation of this stack of
arrow transformers, many arrow transformers provide an ArrowAddBar
class, with methods methods liftBar and elimBar to add and remove
the transformer anywhere in the stack.
|
|
State transformers
|
|
|
An arrow type that provides a modifiable state,
based of section 9 of Generalising Monads to Arrows, by John Hughes,
Science of Computer Programming 37:67-111, May 2000.
| | Methods | | Obtain the current value of the state.
| | | Assign a new value to the state.
|
| | Instances | |
|
|
State readers
|
|
|
An arrow type that provides a read-only state (an environment).
If you also need to modify the state, use ArrowState.
| | Methods | | Obtain the current value of the state.
| | newReader :: a e b -> a (e, r) b | Source |
| Run a subcomputation in the same arrow, but with a different
environment. The environment of the outer computation is
unaffected.
Typical usage in arrow notation:
proc p -> ...
(|newReader cmd|) env
|
| | Instances | |
|
|
Monoid writers
|
|
|
An arrow type that collects additional output (of some Monoid type).
| | Methods | | Add a piece of additional output.
| | newWriter :: a e b -> a e (b, w) | Source |
| Run a subcomputation in the same arrow, making its additional
output accessible.
Typical usage in arrow notation:
proc p -> do
...
(value, output) <- (|newWriter cmd|)
|
| | Instances | |
|
|
Errors
|
|
|
An arrow type that includes errors (or exceptions).
Minimal definition: raise and tryInUnless.
TODO: the operations here are inconsistent with other arrow transformers.
| | Methods | | Raise an error.
| | | :: | | => a e b | computation that may raise errors
| -> a (e, ex) b | computation to handle errors
| -> a e b | | Traditional exception construct.
Typical usage in arrow notation:
proc p -> ...
body `handle` \ex -> handler
|
| | | :: | | => a e b | computation that may raise errors
| -> a (e, b) c | computation to receive successful results
| -> a (e, ex) c | computation to handle errors
| -> a e c | | Exception construct in the style of Exceptional Syntax,
by Nick Benton and Andrew Kennedy, JFP 11(4):395-410, July 2001.
Typical usage in arrow notation:
proc p -> ...
(|tryInUnless
body
(\res -> success)
(\ex -> handler)
|)
|
| | | Handler that returns the error as a value.
|
| | Instances | |
|
|
|
:: (ArrowError ex a, ArrowChoice a) | | => a e b | computation that may raise errors
| -> a (e, b) c | computation to receive successful results
| -> a (e, ex) c | computation to handle errors
| -> a e c | | A suitable value for tryInUnless when the arrow type belongs to
ArrowChoice. To use it, you must define either handle or newError.
|
|
|
Synchronous circuits
|
|
|
An arrow type that can be used to interpret synchronous circuits.
| | Methods | | :: | | => b | the value to return initially.
| -> a b b | an arrow that propagates its input
with a one-tick delay.
| A delay component.
|
|
| | Instances | |
|
|
Produced by Haddock version 2.4.2 |