From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id CBEB5BB84 for ; Mon, 15 May 2006 10:07:46 +0200 (CEST) Received: from cesarox.flet.keio.ac.jp (cesarox.flet.keio.ac.jp [131.113.203.78]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k4F87jTv029696 for ; Mon, 15 May 2006 10:07:46 +0200 Received: from [131.113.203.71] (abelard2.flet.keio.ac.jp [131.113.203.71]) by cesarox.flet.keio.ac.jp (Postfix) with ESMTP id 1E3C8252B85; Mon, 15 May 2006 17:07:43 +0900 (JST) Message-ID: <44683723.1060206@crans.org> Date: Mon, 15 May 2006 17:09:07 +0900 From: Stephane Glondu User-Agent: Thunderbird 1.5 (Macintosh/20051201) MIME-Version: 1.0 To: Charles Bouillaguet Cc: caml-list@yquem.inria.fr, DooMeeR Subject: Re: [Caml-list] Recursive Variant problem.. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 446836D1.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; recursive:01 variants:01 recursive:01 variants:01 hashtbl:01 compiler:01 abstracting:01 reuse:01 cvs:01 ocaml:01 romain:01 romain:01 universty:01 unnamed:98 wrote:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Charles Bouillaguet wrote: > I would like to write a type which describe some kind of term in a toy > programming language. It has sets, but not sets of sets > [...] > a) is it possible to write that with polymorphic variants, and how ? > b) Is it possible to wrote that with Recursive modules, and how ? It reminds me of the following: ------------------------------------------------------------------------ ** Norman Ramsey asked and Jacques Garrigue answered: > 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? Have a look at "Private rows: abstracting the unnamed" and "Code reuse through polymorphic variants" at They both give examples of how to define extensible languages using polymorphic variants. The first one relies on an experimental feature only available in the CVS version of ocaml. ======================================================================== I haven't read the papers yet, so I cannot go further. > I'm CC-ing my classmate Romain (Hi, Romain !), as he may be interested... And what about me? :-( -- Stephane Glondu ENS de Cachan, currently visiting Keio Universty (Tokyo)