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 5A977BB9A for ; Tue, 25 Oct 2005 11:49:14 +0200 (CEST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j9P9nCue008053 for ; Tue, 25 Oct 2005 11:49:13 +0200 Received: from localhost (orion [130.54.16.5]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j9P9n7Rq029764; Tue, 25 Oct 2005 18:49:07 +0900 (JST) Date: Tue, 25 Oct 2005 18:49:07 +0900 (JST) Message-Id: <20051025.184907.68544007.keiko@kurims.kyoto-u.ac.jp> To: virgile.prevosto@m4x.org Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] any types in signatures of functor arguments From: Keiko Nakata In-Reply-To: <20051025105345.319f8366@aloxe.inria.fr> References: <20051025.112220.68541121.keiko@kurims.kyoto-u.ac.jp> <20051025105345.319f8366@aloxe.inria.fr> X-Mailer: Mew version 4.2 on Emacs 20.7 / Mule 4.1 (AOI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 435DFF98.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 functor:01 struct:01 sig:01 val:01 struct:01 summarized:01 subst:01 subst:01 sig:01 val:01 rec:01 verbose:01 fist:98 signatures: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 From: Virgile Prevosto > It might be possible to only modify the arguments you give to F, with > the use of include: > > module M = struct let f (`A x) = x end > > module F(X:sig type s type t = [ `A of s] val f: t -> int end) = > struct let f = function `A _ as a -> X.f a | `B -> 0 > end;; > > module FM = F(struct include M type s = int type t = [ `A of s ]) 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. Regard, Keiko NAKATA