caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Mikkel Fahnøe Jørgensen" <mikkel@dvide.com>
To: "Jacques Carette" <carette@mcmaster.ca>
Cc: OCaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Typing Dynamic Typing in ocaml?
Date: Wed, 17 Dec 2008 21:29:50 +0100	[thread overview]
Message-ID: <caee5ad80812171229g698b9033x23c5fd1a082b4e76@mail.gmail.com> (raw)
In-Reply-To: <494956BD.9030000@mcmaster.ca>

Hi Jacques

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

I'm not really sure I understand exactly what problem you are trying
to solve. But if it is flexible dynamic data structure that can
optionally be associated with a type tag you can take a look at the
source Symbiosis implementation

http://dvide.com/labs/symbiosis/
http://git.dvide.com/pub/symbiosis/tree/myocamlbuild_config.ml

Most of this code is a java script object parser (JSON) which
generates an mostly untyped JSON object tree of lists and maps, but
still has basic float, int and string types.

The actual Symbiosis logic is a thin layer on top of this to access
different configuration logic.

One interesting part of this is the object navigation: each node is
represented as <node, pos> where node is one of the basic JSON types.
Any navigation into the JSON tree results in a new position, but the
position remains separate from the tree. Whenever an expected value is
not found, an exception is thrown and the position is used to report
the error location.

In some sense this attached position corresponds to dynamic type
information. You could view navigation as a computation and attach
type. For example matrix multiplying two JSON lists and attached the
resulting dimensions to the resulting JSON object tree.
I guess this can also be formulated as a monad somehow.

Perhaps this can be of some inspiration, or perhaps it is a different
problem you are trying to solve.

Regards,
Mikkel


  parent reply	other threads:[~2008-12-17 20:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-17 19:45 Jacques Carette
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 [this message]
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=caee5ad80812171229g698b9033x23c5fd1a082b4e76@mail.gmail.com \
    --to=mikkel@dvide.com \
    --cc=caml-list@inria.fr \
    --cc=carette@mcmaster.ca \
    /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).