English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
recursive modules: Cannot safely evaluate the definition
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-04-04 (16:17)
From: Sebastien Ferre <Sebastien.Ferre@i...>
Subject: Re: [Caml-list] recursive modules: Cannot safely evaluate the definition

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.


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.