Commit 338dbad4 authored by ross's avatar ross

[project @ 2004-08-31 16:02:42 by ross]

markup fixes (and one typo) in arrow notation section
parent 332e20e5
......@@ -3619,8 +3619,8 @@ The first line sends the value of <literal>x+1</literal> as an input to
the arrow <literal>f</literal>, and matches its output against
<literal>y</literal>.
In the next line, the output is discarded.
The arrow <literal>returnA</literal> is defined in the
<ulink url="../base/Control.Arrow.html"><literal>Control.Arrow</literal></ulink>
The arrow <function>returnA</function> is defined in the
<ulink url="../libraries/base/Control.Arrow.html"><literal>Control.Arrow</literal></ulink>
module as <literal>arr id</literal>.
The above example is treated as an abbreviation for
<screen>
......@@ -3637,7 +3637,7 @@ arr (\ x -> (x, x)) >>>
Note that variables not used later in the composition are projected out.
After simplification using rewrite rules (see <xref linkend="rewrite-rules"/>)
defined in the
<ulink url="../base/Control.Arrow.html"><literal>Control.Arrow</literal></ulink>
<ulink url="../libraries/base/Control.Arrow.html"><literal>Control.Arrow</literal></ulink>
module, this reduces to
<screen>
arr (\ x -> (x+1, x)) >>>
......@@ -3662,14 +3662,14 @@ so polymorphic variables are allowed.
<para>
It's also possible to have mutually recursive bindings,
using the new <literal>rec</literal> keyword, as in the following example:
<screen>
<programlisting>
counter :: ArrowCircuit a => a Bool Int
counter = proc reset -> do
rec output &lt;- returnA -&lt; if reset then 0 else next
next &lt;- delay 0 -&lt; output+1
returnA -&lt; output
</screen>
The translation of such forms uses the <literal>loop</literal> combinator,
</programlisting>
The translation of such forms uses the <function>loop</function> combinator,
so the arrow concerned must belong to the <literal>ArrowLoop</literal> class.
</para>
......@@ -3693,7 +3693,7 @@ which is translated to
arr (\ (x,y) -> if f x y then Left x else Right y) >>>
(arr (\x -> x+1) >>> f) ||| (arr (\y -> y+2) >>> g)
</screen>
Since the translation uses <literal>|||</literal>,
Since the translation uses <function>|||</function>,
the arrow concerned must belong to the <literal>ArrowChoice</literal> class.
</para>
......@@ -3769,7 +3769,7 @@ and satisfy the corresponding naturality property
arr k >>> (f &lt;+> g) = (arr k >>> f) &lt;+> (arr k >>> g)
</screen>
at least for strict <literal>k</literal>.
(This should be automatic if you're not using <literal>seq</literal>.)
(This should be automatic if you're not using <function>seq</function>.)
This ensures that environments seen by the subcommands are environments
of the whole command,
and also allows the translation to safely trim these environments.
......@@ -3825,7 +3825,7 @@ we are talking about commands, and something different is going on.
The input to the arrow represented by a command consists of values for
the free local variables in the command, plus a stack of anonymous values.
In all the prior examples, this stack was empty.
In the second argument to <literal>handleA</literal>,
In the second argument to <function>handleA</function>,
this stack consists of one value, the value of the exception.
The command form of lambda merely gives this value a name.
</para>
......@@ -3833,8 +3833,9 @@ The command form of lambda merely gives this value a name.
<para>
More concretely,
the values on the stack are paired to the right of the environment.
So when designing operators like <literal>handleA</literal> that pass
extra inputs to their subcommands,
So operators like <function>handleA</function> that pass
extra inputs to their subcommands can be designed for use with the notation
by pairing the values with the environment in this way.
More precisely, the type of each argument of the operator (and its result)
should have the form
<screen>
......@@ -3862,7 +3863,7 @@ proc x -> do
(|runReader (do { ... })|) s
</screen>
which adds <literal>s</literal> to the stack of inputs to the command
built using <literal>runReader</literal>.
built using <function>runReader</function>.
</para>
<para>
......@@ -3880,7 +3881,7 @@ u `bind` f = returnA &amp;&amp;&amp; u >>> f
bind_ :: Arrow a => a e b -> a e c -> a e c
u `bind_` f = u `bind` (arr fst >>> f)
</programlisting>
We could simulate <literal>do</literal> by defining
We could simulate <literal>if</literal> by defining
<programlisting>
cond :: ArrowChoice a => a e b -> a e b -> a (e,Bool) b
cond f g = arr (\ (e,b) -> if b then Left e else Right e) >>> f ||| g
......@@ -3931,7 +3932,7 @@ additional restrictions:
<listitem>
<para>
The module must import
<ulink url="../base/Control.Arrow.html"><literal>Control.Arrow</literal></ulink>.
<ulink url="../libraries/base/Control.Arrow.html"><literal>Control.Arrow</literal></ulink>.
</para>
</listitem>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment