Arrow Libraries (arrows package)ParentContentsIndex
Control.Arrow.Transformer.Error
Portability non-portable (multi-parameter type classes)
Stability experimental
Maintainer ross@soi.city.ac.uk
Description

An arrow transformer that adds error handling.

TODO: the operations here are inconsistent with other arrow transformers.

Synopsis
data ErrorArrow ex a b c
runError :: ArrowChoice a => ErrorArrow ex a e b -> a (e, ex) b -> a e b
class (ArrowError ex a, Arrow a') => ArrowAddError ex a a' | a -> a' where
liftError :: a' e b -> a e b
elimError :: a e b -> a' (e, ex) b -> a' e b
module Control.Arrow.Operations
module Control.Arrow.Transformer
Documentation
data ErrorArrow ex a b c
An arrow that augments an existing arrow with possible errors. The ArrowError class contains methods for raising and handling these errors.
Instances
ArrowChoice a => Arrow (ErrorArrow ex a)
ArrowChoice a => ArrowAddError ex (ErrorArrow ex a) a
(ArrowAddReader r a a', ArrowChoice a, ArrowChoice a') => ArrowAddReader r (ErrorArrow ex a) (ErrorArrow ex a')
(ArrowAddReader r a a', ArrowChoice a, ArrowChoice a') => ArrowAddReader r (ErrorArrow ex a) (ErrorArrow ex a')
(ArrowAddState s a a', ArrowChoice a, ArrowChoice a') => ArrowAddState s (ErrorArrow ex a) (ErrorArrow ex a')
(ArrowAddState s a a', ArrowChoice a, ArrowChoice a') => ArrowAddState s (ErrorArrow ex a) (ErrorArrow ex a')
(ArrowAddWriter w a a', ArrowChoice a, ArrowChoice a') => ArrowAddWriter w (ErrorArrow ex a) (ErrorArrow ex a')
(ArrowAddWriter w a a', ArrowChoice a, ArrowChoice a') => ArrowAddWriter w (ErrorArrow ex a) (ErrorArrow ex a')
(ArrowChoice a, ArrowApply a) => ArrowApply (ErrorArrow ex a)
ArrowChoice a => ArrowChoice (ErrorArrow ex a)
ArrowChoice a => ArrowError ex (ErrorArrow ex a)
(ArrowChoice a, ArrowLoop a) => ArrowLoop (ErrorArrow ex a)
(Monoid ex, ArrowChoice a) => ArrowPlus (ErrorArrow ex a)
(ArrowReader r a, ArrowChoice a) => ArrowReader r (ErrorArrow ex a)
(ArrowState s a, ArrowChoice a) => ArrowState s (ErrorArrow ex a)
ArrowChoice a => ArrowTransformer (ErrorArrow ex) a
(ArrowWriter w a, ArrowChoice a) => ArrowWriter w (ErrorArrow ex a)
(Monoid ex, ArrowChoice a) => ArrowZero (ErrorArrow ex a)
runError
:: ArrowChoice a
=> ErrorArrow ex a e bcomputation that may raise errors
-> a (e, ex) bcomputation to handle errors
-> a e b

Encapsulate an error-raising computation, by completely handling any errors.

Typical usage in arrow notation:

	proc p -> ...
		body `runError` \ex -> handler
class (ArrowError ex a, Arrow a') => ArrowAddError ex a a' | a -> a' where

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

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

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

Typical usage in arrow notation:

	proc p -> ...
		body `elimError` \ex -> handler
Instances
ArrowChoice a => ArrowAddError ex (ErrorArrow ex a) a
ArrowAddError ex a a' => ArrowAddError ex (ReaderArrow r a) (ReaderArrow r a')
ArrowAddError ex a a' => ArrowAddError ex (StateArrow s a) (StateArrow s a')
(ArrowAddError ex a a', Sequence f) => ArrowAddError ex (StaticArrow f a) (StaticArrow f a')
(ArrowAddError ex a a', Monoid w) => ArrowAddError ex (WriterArrow w a) (WriterArrow w a')
module Control.Arrow.Operations
module Control.Arrow.Transformer
Produced by Haddock version 0.5