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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id E27F4BBCA for ; Fri, 4 Apr 2008 18:17:02 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.25,605,1199660400"; d="scan'208";a="11081883" Received: from eltanin.irisa.fr (HELO [131.254.14.123]) ([131.254.14.123]) by mail3-relais-sop.national.inria.fr with ESMTP; 04 Apr 2008 18:17:02 +0200 Message-ID: <47F6547E.3040303@irisa.fr> Date: Fri, 04 Apr 2008 18:17:02 +0200 From: Sebastien Ferre Organization: IRISA User-Agent: Thunderbird 1.5.0.12 (X11/20070530) MIME-Version: 1.0 To: Keiko Nakata , caml-list@yquem.inria.fr Subject: Re: [Caml-list] recursive modules: Cannot safely evaluate the definition References: <20080404.180015.125124978.keiko@kurims.kyoto-u.ac.jp> <47F622A5.9060707@lri.fr> <20080405.004516.46634800.keiko@kurims.kyoto-u.ac.jp> In-Reply-To: <20080405.004516.46634800.keiko@kurims.kyoto-u.ac.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; irisa:01 recursive:01 functors:01 recursive:01 ocaml:01 functor:01 sig:01 sig:01 val:01 functor:01 struct:01 val:01 functors:01 irisa:01 ocaml:01 Hi, Keiko Nakata wrote: > Thank you for the correction and citation. > >> Keiko Nakata wrote: >> > I think that functors cannot be recursive in the current OCaml. > > Yes, I was incorrect. > We have: > > module rec F: functor (X:sig end) -> sig val f : int -> int end = > functor(X:sig end) -> struct > let f x = if x = 0 then 0 else M.f (x-1) > end > > and M : sig val f: int -> int end = F(M) > > This should imply interesting examples are available. For such examples, you can look at my library LogFun, which massively uses functors and recursive modules. http://www.irisa.fr/LIS/ferre/logfun/ It defines a set of components, in the form of OCaml functors, which can be composed in a recursive way. The most illustrative component is the file 'mltype.ml' that defines a language of ML types and patterns by a recursive combination of simpler components. It is used in Camelis (http://www.irisa.fr/LIS/ferre/camelis/) for browsing ML functions from a set of .mli files. It is not very well documented, but if you are interested, you can contact me. Best, Sebastien