From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] GADT constructor syntax
Date: Mon, 6 Dec 2010 10:11:00 +0100 [thread overview]
Message-ID: <20101206091100.GA21369@yquem.inria.fr> (raw)
In-Reply-To: <1245532236.1431213.1291490707868.JavaMail.root@zmbs3.inria.fr>
Hi,
On Sat, Dec 04, 2010 at 08:25:07PM +0100, Jacques Le Normand wrote:
> option a)
> type _ t =
> TrueLit : bool t
> | IntLit of int : int lit
> option b)
> type _ t =
> TrueLit : bool t
> | IntLit : int -> int lit
For a:
A little bit easier to parse (as a Camlp5 designer), which is just
a parse of the 'of' part followed (or not) with the ':' and another
type. In the option b), in the "revised" syntax version, I decided
to also separate the constructor parameters with arrows, which forced
me to add a function separating the ending type, the parsing being
therefore more complicated.
For b:
1/ The difference between normal constructors and constructors with GADT
is very visible. All examples given here are often with definitions
which are relatively short, but I tried an example with constructors
with several long types and I like the idea of seing immediately
that they are GADTs, rather at the end of the definition line (or
lines).
2/ I like the idea of defininig them with a syntax like the one of
functions definitions, like 'val'. In the "revised" syntax version,
where the constructors parameters are in "curried" form, this is
even more readable (even if partially applied parameters are
not accepted in the OCaml compiler).
PS The latest version of Camlp5 works with Jacques' version. You can
download it at: http://pauillac.inria.fr/~ddr/camlp5/
PPS The version with GADT is very interesting to parse parsing rules. I
is what I was searching for many years. In Camlp[45], the EXTEND statement
generates calls to Obj.magic and types constraints to "extend" the
OCaml type system. (This cannot be simulated by first class modules.)
--
Daniel de Rauglaudre
http://pauillac.inria.fr/~ddr/
next parent reply other threads:[~2010-12-06 9:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1245532236.1431213.1291490707868.JavaMail.root@zmbs3.inria.fr>
2010-12-06 9:11 ` Daniel de Rauglaudre [this message]
2010-12-04 19:25 Jacques Le Normand
2010-12-04 19:36 ` [Caml-list] " gasche
2010-12-04 19:39 ` Basile Starynkevitch
2010-12-04 19:41 ` Lukasz Stafiniak
2010-12-04 20:14 ` Jacques Le Normand
2010-12-04 20:22 ` Lukasz Stafiniak
2010-12-04 20:54 ` Jacques Le Normand
2010-12-04 21:00 ` Lukasz Stafiniak
2010-12-04 21:06 ` Jacques Le Normand
2010-12-05 8:10 ` Lukasz Stafiniak
2010-12-05 8:16 ` Lukasz Stafiniak
2010-12-05 8:25 ` Lukasz Stafiniak
2010-12-05 8:35 ` bluestorm
2010-12-06 0:21 ` Jacques Garrigue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101206091100.GA21369@yquem.inria.fr \
--to=daniel.de_rauglaudre@inria.fr \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox