caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Sebastien Ferre <Sebastien.Ferre@irisa.fr>
To: Keiko Nakata <keiko@kurims.kyoto-u.ac.jp>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] recursive modules: Cannot safely evaluate the	definition
Date: Fri, 04 Apr 2008 18:17:02 +0200	[thread overview]
Message-ID: <47F6547E.3040303@irisa.fr> (raw)
In-Reply-To: <20080405.004516.46634800.keiko@kurims.kyoto-u.ac.jp>

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


      reply	other threads:[~2008-04-04 16:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-04  8:44 Hendrik Tews
2008-04-04  9:00 ` [Caml-list] " Keiko Nakata
2008-04-04 12:44   ` Jean-Christophe Filliâtre
2008-04-04 15:23     ` Hendrik Tews
2008-04-04 15:45       ` Keiko Nakata
2008-04-04 16:17         ` Sebastien Ferre [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47F6547E.3040303@irisa.fr \
    --to=sebastien.ferre@irisa.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=keiko@kurims.kyoto-u.ac.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).