caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: nr@eecs.harvard.edu (Norman Ramsey)
To: caml-list@inria.fr
Subject: recursive polymorphic variants?
Date: Thu, 18 Aug 2005 17:27:44 -0400 (EDT)	[thread overview]
Message-ID: <20050818212744.94BD41EB0C3@labrador.eecs.harvard.edu> (raw)

I'm trying to write a small, extensible interpreter, and I'd like to
use polymorphic variants as the extension mechanism.  But I'm getting
stuck on very simple things.  For example, I would like the value type
to include a few simple values, but I would also like it to be
extensible, thus:

  type value = [ `Nil
               | `Number   of float
               | `String   of string
               | `Function of [>value] list -> [>value]
               | `Table    of ([>value], [>value]) Hashtbl.t
               ]

However, when I do this, the compiler complains that

  The type constructor value is not yet completely defined

Is there some way to define a recursive, *extensible* type using
polymorphic variants?  



Norman


             reply	other threads:[~2005-08-18 21:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-18 21:27 Norman Ramsey [this message]
2005-08-18 21:51 ` [Caml-list] " Jacques Garrigue
2005-08-20 11:57   ` skaller
2005-08-20 13:23   ` Jon Harrop
2005-08-20 13:50     ` Alain Frisch

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=20050818212744.94BD41EB0C3@labrador.eecs.harvard.edu \
    --to=nr@eecs.harvard.edu \
    --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).