From: "Jacques Carette" <carette@mcmaster.ca>
To: Jon Harrop <jon@ffconsultancy.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Pervasives.compare output type
Date: Wed, 30 Mar 2005 15:43:19 -0500 [thread overview]
Message-ID: <web-87517767@cgpsrv2.cis.mcmaster.ca> (raw)
In-Reply-To: <200503302106.11361.jon@ffconsultancy.com>
Jon Harrop <jon@ffconsultancy.com> wrote:
> Would someone be so kind as to enlighten me (and probably a few other people!)
> as to what these intruiging GADT things are and what they're good for? :-)
They are a (conservative) extension to Algebraic Data Types (and G=Guarded or Generalized, depending on the author).
The basic idea is that instead of giving names to the various constructors in a Sum type, you give explicit functions
which become the constructors. Furthermore, you then make type inference context-dependent: the type of each
constructor is inferred independently, and can have different 'guards'.
Or at least that's my quick-and-dirty impression, which definitely contains technical inaccuracies, but is roughly
right. To get a good introduction, why not turn to
http://pauillac.inria.fr/~fpottier/slides/slides-msr-11-2004.pdf
for a pleasant and informative read. The slides give references as well as example applications.
For more information:
http://research.microsoft.com/Users/simonpj/papers/gadt/gadt.ps.gz
http://citeseer.ist.psu.edu/669510.html (and several more at http://cristal.inria.fr/~simonet/publis/)
http://www.cs.bu.edu/~hwxi/academic/drafts/ATS.pdf [tougher read...]
For interesting but serious discussions:
http://lambda-the-ultimate.org/node/view/552
http://lambda-the-ultimate.org/node/view/116
http://lambda-the-ultimate.org/node/view/290
The most convincing example I have seen is that an eval function for a statically-typed language
let rec eval e =
match e with
| Lit n -> n
| Plus(a,b) -> (eval a) + (eval b)
| True -> true
| False -> false
| And(a,b) -> (eval a) && (eval b)
| If(t,c,a) -> if eval t then eval c else eval a
| IfZero e' -> (eval e') = 0
is currently rejected in ML languages, but with GADTs the above can be accepted, as it can't "go wrong".
Jacques
next prev parent reply other threads:[~2005-03-30 20:43 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-24 18:47 Alex Baretta
2005-03-24 19:41 ` [Caml-list] " Richard Jones
2005-03-24 21:00 ` Marcin 'Qrczak' Kowalczyk
2005-03-24 21:38 ` Bardur Arantsson
2005-03-24 22:07 ` [Caml-list] " Jason Hickey
2005-03-24 22:26 ` brogoff
2005-03-25 9:42 ` Alex Baretta
2005-04-01 5:59 ` Aleksey Nogin
2005-03-24 22:15 ` Marcin 'Qrczak' Kowalczyk
2005-03-24 22:41 ` Bardur Arantsson
2005-03-25 9:43 ` [Caml-list] " Alex Baretta
2005-03-29 7:14 ` [Caml-list] " Oliver Bandel
2005-03-30 14:17 ` Xavier Leroy
2005-03-30 14:45 ` Alex Baretta
2005-03-30 15:11 ` Jacques Carette
2005-03-30 15:28 ` Alex Baretta
2005-03-30 17:47 ` brogoff
2005-03-30 18:21 ` Jacques Carette
2005-03-30 18:49 ` brogoff
2005-03-30 20:06 ` Jon Harrop
2005-03-30 20:43 ` Jacques Carette [this message]
2005-03-30 22:14 ` Christopher Dutchyn
2005-03-31 0:44 ` brogoff
2005-03-30 22:43 ` GADT?? (Re: [Caml-list] Pervasives.compare output type) Oliver Bandel
2005-03-30 22:35 ` [Caml-list] Pervasives.compare output type Oliver Bandel
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=web-87517767@cgpsrv2.cis.mcmaster.ca \
--to=carette@mcmaster.ca \
--cc=caml-list@yquem.inria.fr \
--cc=jon@ffconsultancy.com \
/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