From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 90C84BBAF for ; Wed, 17 Dec 2008 20:45:36 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.36,238,1228086000"; d="scan'208";a="18601976" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 17 Dec 2008 20:45:36 +0100 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id mBHJjZUf020228 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 17 Dec 2008 20:45:35 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AngBANPlSEmCcUBTgWdsb2JhbACTXQEBCwcECgcRqmRYkSKDBg X-IronPort-AV: E=Sophos;i="4.36,238,1228086000"; d="scan'208";a="18601974" Received: from sigma957.cis.mcmaster.ca ([130.113.64.83]) by mail2-smtp-roc.national.inria.fr with ESMTP; 17 Dec 2008 20:45:34 +0100 Received: from Dura7.UTS.McMaster.CA (dura7.UTS.mcmaster.ca [130.113.196.62]) by sigma957.cis.mcmaster.ca (8.13.7/8.13.7) with ESMTP id mBHJjDsB003822 for ; Wed, 17 Dec 2008 14:45:32 -0500 (EST) Received: from cgpsrv2.cis.mcmaster.ca (univmail.CIS.McMaster.CA [130.113.64.46]) by Dura7.UTS.McMaster.CA (8.13.7/8.13.7) with ESMTP id mBHJitl3020928 for ; Wed, 17 Dec 2008 14:44:55 -0500 Received: from [173.32.147.100] (account carette@univmail.cis.mcmaster.ca HELO [192.168.1.100]) by cgpsrv2.cis.mcmaster.ca (CommuniGate Pro SMTP 4.3.12) with ESMTPSA id 236209302 for caml-list@inria.fr; Wed, 17 Dec 2008 14:44:55 -0500 Message-ID: <494956BD.9030000@mcmaster.ca> Date: Wed, 17 Dec 2008 14:45:01 -0500 From: Jacques Carette Organization: McMaster University User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 To: OCaml Subject: Typing Dynamic Typing in ocaml? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-PMX-Version-Mac: 5.4.2.338381, Antispam-Engine: 2.6.0.325393, Antispam-Data: 2008.12.17.192526 X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='BODY_SIZE_1800_1899 0, BODY_SIZE_5000_LESS 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __USER_AGENT 0' X-Miltered: at discorde with ID 494956DF.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 ocaml:01 computations:01 integers:01 variants:01 variants:01 compiler:01 polymorphic:01 polymorphic:01 typing:01 typing:01 behaviour:01 arbitrary:02 data:02 data:02 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