Browse thread
recursive modules: Cannot safely evaluate the definition
-
Hendrik Tews
-
Keiko Nakata
-
Jean-Christophe_Filliātre
-
Hendrik Tews
-
Keiko Nakata
- Sebastien Ferre
-
Keiko Nakata
-
Hendrik Tews
-
Jean-Christophe_Filliātre
-
Keiko Nakata
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Sebastien Ferre <Sebastien.Ferre@i...> |
| Subject: | Re: [Caml-list] recursive modules: Cannot safely evaluate the definition |
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