caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Rajchenbach-Teller <david.teller@univ-orleans.fr>
To: bob zhang <bobzhang1988@gmail.com>
Cc: Jacques Carette <carette@mcmaster.ca>, Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Polymorphic Variants for big Ast?
Date: Fri, 05 Oct 2012 13:33:06 +0200	[thread overview]
Message-ID: <506EC572.9080906@univ-orleans.fr> (raw)
In-Reply-To: <CANcqPu62z=sOu6L3nYMJ-3pcibUsYNTU2dE_VVoUzQikA2i-fg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 738 bytes --]

For Opa, we used a variant on the technique. We had a rather complex Ast
that was progressively refined through a number of passes.

Each pass could remove or add cases, and we wanted to have type
guarantees that ast nodes did not escape their scope.

To do this, we used something along the lines of

type 'variant Expr =
   | Let of ...
   | ...
   | Variant of 'variant
and 'variant Foo =
   | ...


In which ['variant] was instantiated with a polymorphic variant. This
gave us considerable flexibility and generally avoided the problem of
over-complicated error messages.

You can find the full source code at
https://github.com/MLstate/opalang/blob/master/compiler/opalang/surfaceAst.ml
.

Cheers,
 David


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply	other threads:[~2012-10-05 11:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-04 23:15 bob zhang
2012-10-05  3:19 ` Jacques Carette
2012-10-05  3:38   ` bob zhang
2012-10-05 11:33     ` David Rajchenbach-Teller [this message]
2012-10-05  7:51 ` Pierre-Alexandre Voye

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=506EC572.9080906@univ-orleans.fr \
    --to=david.teller@univ-orleans.fr \
    --cc=bobzhang1988@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=carette@mcmaster.ca \
    /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;
as well as URLs for NNTP newsgroup(s).