@-bindings broken in 6.0?
Simon Peyton-Jones
simonpj@microsoft.com
Wed, 25 Jun 2003 07:55:15 +0100
| > -farrows
|=20
| Is this switch documented somewhere? I looked through the docs in the
| latest CVS version of GHC and couldn't find anything about it ...
Not yet: I only put it in this week! And it's not documented yet.
There are some examples, though
in
fptools/testsuite/tests/ghc-regress/arrows
And the commit message contains many details (enclosed)
Simon
----------------------------------------------
Add support for Ross Paterson's arrow notation
----------------------------------------------
Ross Paterson's ICFP'01 paper described syntax to support John Hughes's
"arrows", rather as do-notation supports monads. Except that
do-notation is
relatively modest -- you can write monads by hand without much trouble
--
whereas arrow-notation is more-or-less essential for writing arrow
programs.
It desugars to a massive pile of tuple construction and selection!
For some time, Ross has had a pre-processor for arrow notation, but the
resulting type error messages (reported in terms of the desugared code)
are impenetrable. This commit integrates the syntax into GHC. The=20
type error messages almost certainly still require tuning, but they
should
be better than with the pre-processor.
Main syntactic changes (enabled with -farrows)
=20
exp ::=3D ... | proc pat -> cmd
cmd ::=3D exp1 -< exp2 | exp1 >- exp2
| exp1 -<< exp2 | exp1 >>- exp2
| \ pat1 .. patn -> cmd
| let decls in cmd
| if exp then cmd1 else cmd2
| do { cstmt1 .. cstmtn ; cmd }
| (| exp |) cmd1 .. cmdn
| cmd1 qop cmd2
| case exp of { calts }
cstmt :: =3D let decls
| pat <- cmd
| rec { cstmt1 .. cstmtn }
| cmd
New keywords and symbols:
proc rec
-< >- -<< >>- =20
(| |)
The do-notation in cmds was not described in Ross's ICFP'01 paper;
instead
it's in his chapter in The Fun of Programming (Plagrave 2003).
The four arrow-tail forms (-<) etc cover=20
(a) which order the pices come in (-< vs >-), and=20
(b) whether the locally bound variables can be used in the
arrow part (-< vs -<<) . =20
In previous presentations, the higher-order-ness (b) was inferred,
but it makes a big difference to the typing required so it seems more
consistent to be explicit.
The 'rec' form is also available in do-notation:
* you can use 'rec' in an ordinary do, with the obvious meaning
* using 'mdo' just says "infer the minimal recs"
Still to do
~~~~~~~~~~~
Top priority is the user manual.
The implementation still lacks an implementation of
the case form of cmd.
Implementation notes
~~~~~~~~~~~~~~~~~~~~
Cmds are parsed, and indeed renamed, as expressions. The type checker=20
distinguishes the two. =20