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 (12:43)
From: Jean-Christophe_Filliâtre <Jean-Christophe.Filliatre@l...>
Subject: Re: [Caml-list] recursive modules: Cannot safely evaluate the definition
Keiko Nakata wrote:
> Hello.
> I think that functors cannot be recursive in the current OCaml.

They can:

module type S = sig type t = int end

module rec F : functor(X : S) -> S = functor(X: S) -> struct
  type t = M.t
and M : S = F(struct type t = int end)

let x : M.t = 42

But it is likely that you won't do anything useful with a functor like
this (try adding a "val x : t" in the signature and to define x in F as
equal to M.x and you'll bump on the "Cannot safely evaluate the
definition of ..." error).