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 concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 61AEBBB9A for ; Tue, 25 Oct 2005 12:00:36 +0200 (CEST) Received: from smtp01.uc3m.es (smtp01.uc3m.es [163.117.136.121]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j9PA0ZPL009241 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=FAIL) for ; Tue, 25 Oct 2005 12:00:36 +0200 Received: from smtp01.uc3m.es (localhost [127.0.0.1]) by localhost.uc3m.es (Postfix) with ESMTP id 3E2E09D215 for ; Tue, 25 Oct 2005 12:00:35 +0200 (CEST) Received: from ariel.tsc.uc3m.es (ariel.tsc.uc3m.es [163.117.145.25]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by smtp01.uc3m.es (Postfix) with ESMTP id 168A29D0A9 for ; Tue, 25 Oct 2005 12:00:35 +0200 (CEST) Received: from umbriel.tsc.uc3m.es (umbriel.tsc.uc3m.es [163.117.145.225]) by ariel.tsc.uc3m.es (8.13.4/8.13.4) with ESMTP id j9PA0Vhl011356 for ; Tue, 25 Oct 2005 12:00:32 +0200 DomainKey-Signature: a=rsa-sha1; s=dtsc-uc3m; d=tsc.uc3m.es; c=simple; q=dns; h=received:date:from:subject:in-reply-to:to:cc:message-id: mime-version:content-type:content-transfer-encoding: x-accept-language:references:user-agent:received-spf; b=fiDB/akdhszXkZvjBtyaRsCYe/h2anGk2dmSMmJhdpSiTzBg2yPs8O4cdxewSD40g ver6XGuPOAti+LddCv5qw== Received: from [163.117.145.58] by umbriel.tsc.uc3m.es (Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005)) with ESMTPS id <0IOW00FYYUGWPNF0@umbriel.tsc.uc3m.es> for caml-list@yquem.inria.fr; Tue, 25 Oct 2005 12:00:32 +0200 (CEST) Date: Tue, 25 Oct 2005 12:08:45 +0200 From: fva en UMBRIEL Subject: Re: [Caml-list] any types in signatures of functor arguments In-reply-to: <20051025.184907.68544007.keiko@kurims.kyoto-u.ac.jp> To: Keiko Nakata Cc: caml-list@yquem.inria.fr Message-id: <435E042D.1060709@tsc.uc3m.es> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en References: <20051025.112220.68541121.keiko@kurims.kyoto-u.ac.jp> <20051025105345.319f8366@aloxe.inria.fr> <20051025.184907.68544007.keiko@kurims.kyoto-u.ac.jp> User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929) Received-SPF: pass (ariel.tsc.uc3m.es: 163.117.145.225 is whitelisted) receiver=ariel.tsc.uc3m.es; client-ip=163.117.145.225; helo=umbriel.tsc.uc3m.es; envelope-from=fva@tsc.uc3m.es; x-software=spfmilter 0.95 http://www.acme.com/software/spfmilter/ with libspf2; X-TSC-MailScanner-Information: e-mail scanned by MailSystem in DTSC-UC3M X-TSC-MailScanner: Found to be clean X-TSC-MailScanner-From: fva@tsc.uc3m.es X-Miltered: at concorde with ID 435E0243.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 functor:01 overkill:01 variants:01 valverde:01 summarized:01 subst:01 struct:01 subst:01 struct:01 sig:01 val:01 rec:01 verbose:01 fist:98 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=SPF_FAIL autolearn=disabled version=3.0.3 Hi, given your problem I wonder whether the use of modules, if elegant, is not overkill. I recall an extensible solution to such syntactic trees written with polymorphic variants in one of the papers/tutorials by Jacques Garrigue. Perhaps you could have a look at those for inspiration. Regards F. Valverde Keiko Nakata wrote: >Thanks for the reply. > >I should describe my program in more detail. >What I want to do would be summarized in the following program. >(Suppose that modules Int, String, and Subst are in separate files, >and have many more type definitions and functions actually.) > >module Int = struct > type mexp = [`Str of item list | `Var of string] > and item = [`Mod of mexp | `Term of int] > type env = (string * mexp) list > let subst env name = List.assoc name env >end > >module String = struct > type mexp = [`Str of item list | `Var of string] > and item = [`Mod of mexp | `Term of string] > type env = (string * mexp) list > let subst env name = List.assoc name env >end > >module Subst (X: sig > type mexp = [`Str of item list | `Var of string] > and item = [`Mod of mexp | `Term of _ ] > type env = (string * mexp) list > val subst : env -> string -> mexp end) = struct > let rec subst_mexp env = function > `Str items -> `Str (List.map (subst_item env) items) > | `Var name -> X.subst env name > and subst_item env = function > `Mod mexp -> `Mod (subst_mexp env mexp) > | `Term t -> `Term t > end > > >One may say that I should fist define the type item0 as > >type ('a,'b) item0 = [`Mod of 'a | `Term of 'b ] > >then define type mexp and item as > >type mexp = [`Str of item list | `Var of string] >and item = (mexp, int) item0 > >This will work. >However, I cannot decide where to put the definition of item0 >when Int and String are in separate files. >Additionally, while it will not a big problem, >this encoding will make my program more verbose. > >