arrows-0.2: Arrow classes and transformersSource codeContentsIndex
Portabilitynon-portable (multi-parameter type classes)
An arrow transformer that adds a modifiable state, based of section 9 of Generalising Monads to Arrows, by John Hughes, Science of Computer Programming 37:67-111, May 2000.
data StateArrow s a b c
runState :: Arrow a => StateArrow s a e b -> a (e, s) (b, s)
class (ArrowState s a, Arrow a') => ArrowAddState s a a' | a -> a' where
liftState :: a' e b -> a e b
elimState :: a e b -> a' (e, s) (b, s)
data StateArrow s a b c Source
An arrow type that augments an existing arrow with a modifiable state. The ArrowState class contains the operations on this state.
show/hide Instances
runState :: Arrow a => StateArrow s a e b -> a (e, s) (b, s)Source

Encapsulation of a state-using computation, exposing the initial and final states.

Typical usage in arrow notation:

	proc p -> do
		(result, final_state) <- (|runState cmd|) init_state
class (ArrowState s a, Arrow a') => ArrowAddState s a a' | a -> a' whereSource

Adding a Control.Arrow.Transformer.State.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 Control.Arrow.Transformer.lift method of the Control.Arrow.Transformer.ArrowTransformer class, or remove a state transformer from the top of the stack using the Control.Arrow.Transformer.State.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 Control.Arrow.Transformer.lift and Control.Arrow.Transformer.State.runState respectively. Instances are lifted through other transformers with

	instance ArrowAddState s a a' =>
		ArrowAddState s (FooArrow a) (FooArrow a')
liftState :: a' e b -> a e bSource
elimState :: a e b -> a' (e, s) (b, s)Source
show/hide Instances
Produced by Haddock version 2.3.0