caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Arnaud Spiwack <aspiwack@lix.polytechnique.fr>
To: caml-list@inria.fr
Subject: Existential types and W
Date: Fri, 08 Jun 2007 22:41:03 +0200	[thread overview]
Message-ID: <4669BEDF.9010109@lix.polytechnique.fr> (raw)

Hi caml list ! How are you today ?

The other day I ran into this fascinating experience, since then I just 
can't avoid but try and investigate it (a little). I was trying to 
devise a data type representing interactively defined (Coq) terms. It 
does not really matter, but when I was thinking of the essence of this 
object, it looked something like :

type 'a node = { subterms : [`Leaf of 'b hole | `Node of 'b node] list;
                          build : 'b -> 'a }

The idea was that you open a list of new subterms to define (called 
goals), you solve them, then you use the function to create a term of 
type 'a. But, what? That requires existential types!

First time ever I had a use in a non-dependently typed program of 
existential types. That was quite a thrill, really. I spent like an hour 
looking at this type amazed. But well, looking at it does not really 
change the fact : that can't be written in OCaml (please correct me if 
I'm wrong).

Of course in Coq (or any such system), it's rather straightfoward to 
define ( here goes a Coq definition, in case anyone is interested :
Inductive subterm (B:Type)  (node:Type->Type) : Type:=
  | Leaf : hole B -> subterm B node
  | Node : node B -> subterm B node
.

Inductive node : forall A:Type, Type :=
  mkNode : forall (A B:Type) (subterms : subterm B node) (build : B -> 
A), node A. )

                 
There go two questions (three if you count "is there possibly a way to 
do that in OCaml that I've missed?") :
1/ Do the reader of this list encounter the need of existential type often?
2/ How would the addition of existential types impact the typing 
algorithm of OCaml? (because I must confess that I have absolutely no 
clue, would there still be a principal type to every expression? would 
that increase complexity?)



Arnaud Spiwack


             reply	other threads:[~2007-06-08 20:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-08 20:41 Arnaud Spiwack [this message]
2007-06-08 21:54 ` [Caml-list] " Daniel Bünzli

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=4669BEDF.9010109@lix.polytechnique.fr \
    --to=aspiwack@lix.polytechnique.fr \
    --cc=caml-list@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;
as well as URLs for NNTP newsgroup(s).