Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,326
Issues
4,326
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
390
Merge Requests
390
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
338dbad4
Commit
338dbad4
authored
Aug 31, 2004
by
ross
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[project @ 2004-08-31 16:02:42 by ross]
markup fixes (and one typo) in arrow notation section
parent
332e20e5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
14 deletions
+15
-14
ghc/docs/users_guide/glasgow_exts.xml
ghc/docs/users_guide/glasgow_exts.xml
+15
-14
No files found.
ghc/docs/users_guide/glasgow_exts.xml
View file @
338dbad4
...
@@ -3619,8 +3619,8 @@ The first line sends the value of <literal>x+1</literal> as an input to
...
@@ -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
the arrow
<literal>
f
</literal>
, and matches its output against
<literal>
y
</literal>
.
<literal>
y
</literal>
.
In the next line, the output is discarded.
In the next line, the output is discarded.
The arrow
<
literal>
returnA
</literal
>
is defined in the
The arrow
<
function>
returnA
</function
>
is 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 as
<literal>
arr id
</literal>
.
module as
<literal>
arr id
</literal>
.
The above example is treated as an abbreviation for
The above example is treated as an abbreviation for
<screen>
<screen>
...
@@ -3637,7 +3637,7 @@ arr (\ x -> (x, x)) >>>
...
@@ -3637,7 +3637,7 @@ arr (\ x -> (x, x)) >>>
Note that variables not used later in the composition are projected out.
Note that variables not used later in the composition are projected out.
After simplification using rewrite rules (see
<xref
linkend=
"rewrite-rules"
/>
)
After simplification using rewrite rules (see
<xref
linkend=
"rewrite-rules"
/>
)
defined in the
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
module, this reduces to
<screen>
<screen>
arr (\ x -> (x+1, x)) >>>
arr (\ x -> (x+1, x)) >>>
...
@@ -3662,14 +3662,14 @@ so polymorphic variables are allowed.
...
@@ -3662,14 +3662,14 @@ so polymorphic variables are allowed.
<para>
<para>
It's also possible to have mutually recursive bindings,
It's also possible to have mutually recursive bindings,
using the new
<literal>
rec
</literal>
keyword, as in the following example:
using the new
<literal>
rec
</literal>
keyword, as in the following example:
<
screen
>
<
programlisting
>
counter :: ArrowCircuit a => a Bool Int
counter :: ArrowCircuit a => a Bool Int
counter = proc reset -> do
counter = proc reset -> do
rec output
<
- returnA -
<
if reset then 0 else next
rec output
<
- returnA -
<
if reset then 0 else next
next
<
- delay 0 -
<
output+1
next
<
- delay 0 -
<
output+1
returnA -
<
output
returnA -
<
output
</
screen
>
</
programlisting
>
The translation of such forms uses the
<
literal>
loop
</literal
>
combinator,
The translation of such forms uses the
<
function>
loop
</function
>
combinator,
so the arrow concerned must belong to the
<literal>
ArrowLoop
</literal>
class.
so the arrow concerned must belong to the
<literal>
ArrowLoop
</literal>
class.
</para>
</para>
...
@@ -3693,7 +3693,7 @@ which is translated to
...
@@ -3693,7 +3693,7 @@ which is translated to
arr (\ (x,y) -> if f x y then Left x else Right y) >>>
arr (\ (x,y) -> if f x y then Left x else Right y) >>>
(arr (\x -> x+1) >>> f) ||| (arr (\y -> y+2) >>> g)
(arr (\x -> x+1) >>> f) ||| (arr (\y -> y+2) >>> g)
</screen>
</screen>
Since the translation uses
<
literal>
|||
</literal
>
,
Since the translation uses
<
function>
|||
</function
>
,
the arrow concerned must belong to the
<literal>
ArrowChoice
</literal>
class.
the arrow concerned must belong to the
<literal>
ArrowChoice
</literal>
class.
</para>
</para>
...
@@ -3769,7 +3769,7 @@ and satisfy the corresponding naturality property
...
@@ -3769,7 +3769,7 @@ and satisfy the corresponding naturality property
arr k >>> (f
<
+> g) = (arr k >>> f)
<
+> (arr k >>> g)
arr k >>> (f
<
+> g) = (arr k >>> f)
<
+> (arr k >>> g)
</screen>
</screen>
at least for strict
<literal>
k
</literal>
.
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
This ensures that environments seen by the subcommands are environments
of the whole command,
of the whole command,
and also allows the translation to safely trim these environments.
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.
...
@@ -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 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.
the free local variables in the command, plus a stack of anonymous values.
In all the prior examples, this stack was empty.
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.
this stack consists of one value, the value of the exception.
The command form of lambda merely gives this value a name.
The command form of lambda merely gives this value a name.
</para>
</para>
...
@@ -3833,8 +3833,9 @@ The command form of lambda merely gives this value a name.
...
@@ -3833,8 +3833,9 @@ The command form of lambda merely gives this value a name.
<para>
<para>
More concretely,
More concretely,
the values on the stack are paired to the right of the environment.
the values on the stack are paired to the right of the environment.
So when designing operators like
<literal>
handleA
</literal>
that pass
So operators like
<function>
handleA
</function>
that pass
extra inputs to their subcommands,
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)
More precisely, the type of each argument of the operator (and its result)
should have the form
should have the form
<screen>
<screen>
...
@@ -3862,7 +3863,7 @@ proc x -> do
...
@@ -3862,7 +3863,7 @@ proc x -> do
(|runReader (do { ... })|) s
(|runReader (do { ... })|) s
</screen>
</screen>
which adds
<literal>
s
</literal>
to the stack of inputs to the command
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>
<para>
<para>
...
@@ -3880,7 +3881,7 @@ u `bind` f = returnA &&& u >>> f
...
@@ -3880,7 +3881,7 @@ u `bind` f = returnA &&& u >>> f
bind_ :: Arrow a => a e b -> a e c -> a e c
bind_ :: Arrow a => a e b -> a e c -> a e c
u `bind_` f = u `bind` (arr fst >>> f)
u `bind_` f = u `bind` (arr fst >>> f)
</programlisting>
</programlisting>
We could simulate
<literal>
do
</literal>
by defining
We could simulate
<literal>
if
</literal>
by defining
<programlisting>
<programlisting>
cond :: ArrowChoice a => a e b -> a e b -> a (e,Bool) b
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
cond f g = arr (\ (e,b) -> if b then Left e else Right e) >>> f ||| g
...
@@ -3931,7 +3932,7 @@ additional restrictions:
...
@@ -3931,7 +3932,7 @@ additional restrictions:
<listitem>
<listitem>
<para>
<para>
The module must import
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>
</para>
</listitem>
</listitem>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment