caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* recursive polymorphic variants?
@ 2005-08-18 21:27 Norman Ramsey
  2005-08-18 21:51 ` [Caml-list] " Jacques Garrigue
  0 siblings, 1 reply; 5+ messages in thread
From: Norman Ramsey @ 2005-08-18 21:27 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-08-20 13:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-18 21:27 recursive polymorphic variants? Norman Ramsey
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

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).