caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Carette <carette@mcmaster.ca>
To: OCaml <caml-list@inria.fr>
Subject: Typing Dynamic Typing in ocaml?
Date: Wed, 17 Dec 2008 14:45:01 -0500	[thread overview]
Message-ID: <494956BD.9030000@mcmaster.ca> (raw)

I have two (related) questions:
1) Has anyone transcribed the TypeRep library into ocaml?
http://people.cs.uu.nl/arthurb/dynamic.html

2) How do I embed 'dynamically known' data into a single ocaml 
data-structure?

More specifically, I am experimenting with a (new) language which allows 
deduction and computations to be performed with equal ease on its 
terms.  This language uses ocaml has the host meta-language (ie the 
interpreter is written in ocaml).  I would like to be able to use 
arbitrary ocaml data-structures to represent some of my terms, when 
these terms are known to come from specific theories.  For example, I 
would like to use Bigint to represent integers, but without exposing 
that per se.  Perhaps a better way to phrase this would be to say that I 
want to have a "generic external data container" type in my language 
terms, which I can instantiate in multiple different ways (in the same 
program), with data handled in different modules, without having to 
change the 'generic' data-structure everytime I add a new module.

Polymorphic variants of course come to mind - but they would force me to 
add a new type parameter to all my types, which I would rather avoid.  I 
would be quite happy to use polymorphic variants if I could 'hide away' 
the extra type parameter involved with open variants.  My attempts at 
hiding this parameter (with existentials) has been too successful, in 
that once hidden I can't extract my data from this container anymore 
[which is the correct behaviour for the compiler].

I thought of using objects too, but my data does not really have any 
common structure, so the object would be a pure container.  I cannot see 
any advantage over polymorphic variants, and all the same headaches of 
an 'extra' polymorphic parameter remain.

Jacques




             reply	other threads:[~2008-12-17 19:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-17 19:45 Jacques Carette [this message]
2008-12-17 19:58 ` [Caml-list] " Stéphane Glondu
2008-12-17 21:08   ` Jacques Carette
2008-12-17 21:15     ` Stéphane Glondu
2008-12-17 21:15     ` Daniel Bünzli
2008-12-17 20:29 ` Mikkel Fahnøe Jørgensen
2008-12-17 21:28 ` David Teller
2008-12-17 22:42 ` Mauricio Fernandez
2008-12-18  1:16 ` Yaron Minsky

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=494956BD.9030000@mcmaster.ca \
    --to=carette@mcmaster.ca \
    --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).