<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Control.Arrow.Transformer.State</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_Control-Arrow-Transformer-State.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Control-Arrow-Transformer-State.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">arrows-0.4.4.1: Arrow classes and transformers</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>non-portable (multi-parameter type classes)</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>ross@soi.city.ac.uk</td></tr><tr><th>Safe Haskell</th><td>Safe-Infered</td></tr></table><p class="caption">Control.Arrow.Transformer.State</p></div><div id="description"><p class="caption">Description</p><div class="doc"><p>An arrow transformer that adds a modifiable state, based of section 9 of <em>Generalising Monads to Arrows</em>, by John Hughes, <em>Science of Computer Programming</em> 37:67-111, May 2000. </p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">newtype</span> <a href="#t:StateArrow">StateArrow</a> s a b c = <a href="#v:StateArrow">StateArrow</a> (a (b, s) (c, s))</li><li class="src short"><a href="#v:runState">runState</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a => <a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a e b -> a (e, s) (b, s)</li><li class="src short"><span class="keyword">class</span> (<a href="Control-Arrow-Operations.html#t:ArrowState">ArrowState</a> s a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a') => <a href="#t:ArrowAddState">ArrowAddState</a> s a a' | a -> a' <span class="keyword">where</span><ul class="subs"><li><a href="#v:liftState">liftState</a> :: a' e b -> a e b</li><li><a href="#v:elimState">elimState</a> :: a e b -> a' (e, s) (b, s)</li></ul></li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><span class="keyword">newtype</span> <a name="t:StateArrow" class="def">StateArrow</a> s a b c <a href="src/Control-Arrow-Transformer-State.html#StateArrow" class="link">Source</a></p><div class="doc"><p>An arrow type that augments an existing arrow with a modifiable state. The <code><a href="Control-Arrow-Operations.html#t:ArrowState">ArrowState</a></code> class contains the operations on this state. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:StateArrow" class="def">StateArrow</a> (a (b, s) (c, s))</td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:StateArrow" class="caption collapser" onclick="toggleSection('i:StateArrow')">Instances</p><div id="section.i:StateArrow" class="show"><table><tr><td class="src"><a href="Control-Arrow-Operations.html#t:ArrowError">ArrowError</a> ex a => <a href="Control-Arrow-Operations.html#t:ArrowError">ArrowError</a> ex (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Arrow-Operations.html#t:ArrowWriter">ArrowWriter</a> w a => <a href="Control-Arrow-Operations.html#t:ArrowWriter">ArrowWriter</a> w (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a => <a href="Control-Arrow-Operations.html#t:ArrowState">ArrowState</a> s (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Arrow-Operations.html#t:ArrowReader">ArrowReader</a> r a => <a href="Control-Arrow-Operations.html#t:ArrowReader">ArrowReader</a> r (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a => <a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a) a</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Arrow-Transformer-Error.html#t:ArrowAddError">ArrowAddError</a> ex a a' => <a href="Control-Arrow-Transformer-Error.html#t:ArrowAddError">ArrowAddError</a> ex (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a) (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a')</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Arrow-Transformer-Writer.html#t:ArrowAddWriter">ArrowAddWriter</a> w a a' => <a href="Control-Arrow-Transformer-Writer.html#t:ArrowAddWriter">ArrowAddWriter</a> w (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a) (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a')</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Arrow-Transformer-Reader.html#t:ArrowAddReader">ArrowAddReader</a> r a a' => <a href="Control-Arrow-Transformer-Reader.html#t:ArrowAddReader">ArrowAddReader</a> r (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a) (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a')</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a => <a href="Control-Arrow-Transformer.html#t:ArrowTransformer">ArrowTransformer</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s) a</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowZero">ArrowZero</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowZero">ArrowZero</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowPlus">ArrowPlus</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowPlus">ArrowPlus</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowChoice">ArrowChoice</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowChoice">ArrowChoice</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowApply">ArrowApply</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowApply">ArrowApply</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowLoop">ArrowLoop</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowLoop">ArrowLoop</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Category.html#t:Category">Category</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Category.html#t:Category">Category</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Arrow-Operations.html#t:ArrowCircuit">ArrowCircuit</a> a => <a href="Control-Arrow-Operations.html#t:ArrowCircuit">ArrowCircuit</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Monad.html#t:Functor">Functor</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a b)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a b)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowPlus">ArrowPlus</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Alternative">Alternative</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a b)</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowPlus">ArrowPlus</a> a => <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Monoid.html#t:Monoid">Monoid</a> (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a b c)</td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:runState" class="def">runState</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a => <a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a e b -> a (e, s) (b, s)<a href="src/Control-Arrow-Transformer-State.html#runState" class="link">Source</a></p><div class="doc"><p>Encapsulation of a state-using computation, exposing the initial and final states. </p><p>Typical usage in arrow notation: </p><pre> proc p -> do ... (result, final_state) <- (|runState cmd|) init_state </pre></div></div><div class="top"><p class="src"><span class="keyword">class</span> (<a href="Control-Arrow-Operations.html#t:ArrowState">ArrowState</a> s a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a') => <a name="t:ArrowAddState" class="def">ArrowAddState</a> s a a' | a -> a' <span class="keyword">where</span><a href="src/Control-Arrow-Internals.html#ArrowAddState" class="link">Source</a></p><div class="doc"><p>Adding a <code><a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a></code> to an arrow type, but not necessarily as the outer arrow transformer. </p><p>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 <code><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Kleisli">Kleisli</a></code> arrow. One can add a transformer to the top of this stack using the <code><a href="Control-Arrow-Transformer.html#v:lift">lift</a></code> method of the <code><a href="Control-Arrow-Transformer.html#t:ArrowTransformer">ArrowTransformer</a></code> class, or remove a state transformer from the top of the stack using the <code><a href="Control-Arrow-Transformer-State.html#v:runState">runState</a></code> encapsulation operator. The methods of this class add and remove state transformers anywhere in the stack. In the instance </p><pre> instance Arrow a => ArrowAddState s (ArrowState s a) a </pre><p>they are equivalent to <code><a href="Control-Arrow-Transformer.html#v:lift">lift</a></code> and <code><a href="Control-Arrow-Transformer-State.html#v:runState">runState</a></code> respectively. Instances are lifted through other transformers with </p><pre> instance ArrowAddState s a a' => ArrowAddState s (FooArrow a) (FooArrow a') </pre></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:liftState" class="def">liftState</a> :: a' e b -> a e b<a href="src/Control-Arrow-Internals.html#liftState" class="link">Source</a></p><div class="doc"><p>Lift a computation from an arrow to one with an added state. </p><p>Typical usage in arrow notation: </p><pre> proc p -> ... (|liftState cmd|) </pre></div><p class="src"><a name="v:elimState" class="def">elimState</a> :: a e b -> a' (e, s) (b, s)<a href="src/Control-Arrow-Internals.html#elimState" class="link">Source</a></p><div class="doc"><p>Elimination of a state transformer from a computation, exposing the initial and final states. </p><p>Typical usage in arrow notation: </p><pre> proc p -> do ... (result, final_state) <- (|elimState cmd|) init_state </pre></div></div><div class="subs instances"><p id="control.i:ArrowAddState" class="caption collapser" onclick="toggleSection('i:ArrowAddState')">Instances</p><div id="section.i:ArrowAddState" class="show"><table><tr><td class="src"><a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> r a a' => <a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> r (<a href="Control-Arrow-Transformer-Automaton.html#t:Automaton">Automaton</a> a) (<a href="Control-Arrow-Transformer-Automaton.html#t:Automaton">Automaton</a> a')</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:Arrow">Arrow</a> a => <a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s (<a href="Control-Arrow-Transformer-State.html#t:StateArrow">StateArrow</a> s a) a</td><td class="doc empty"> </td></tr><tr><td class="src">(<a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s a a', <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowChoice">ArrowChoice</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Arrow.html#t:ArrowChoice">ArrowChoice</a> a') => <a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s (<a href="Control-Arrow-Transformer-Error.html#t:ErrorArrow">ErrorArrow</a> ex a) (<a href="Control-Arrow-Transformer-Error.html#t:ErrorArrow">ErrorArrow</a> ex a')</td><td class="doc empty"> </td></tr><tr><td class="src">(<a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s a a', <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Control-Applicative.html#t:Applicative">Applicative</a> f) => <a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s (<a href="Control-Arrow-Transformer-Static.html#t:StaticArrow">StaticArrow</a> f a) (<a href="Control-Arrow-Transformer-Static.html#t:StaticArrow">StaticArrow</a> f a')</td><td class="doc empty"> </td></tr><tr><td class="src">(<a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s a a', <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Monoid.html#t:Monoid">Monoid</a> w) => <a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s (<a href="Control-Arrow-Transformer-Writer.html#t:WriterArrow">WriterArrow</a> w a) (<a href="Control-Arrow-Transformer-Writer.html#t:WriterArrow">WriterArrow</a> w a')</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s a a' => <a href="Control-Arrow-Transformer-State.html#t:ArrowAddState">ArrowAddState</a> s (<a href="Control-Arrow-Transformer-Reader.html#t:ReaderArrow">ReaderArrow</a> r a) (<a href="Control-Arrow-Transformer-Reader.html#t:ReaderArrow">ReaderArrow</a> r a')</td><td class="doc empty"> </td></tr></table></div></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.10.0</p></div></body></html>