Version franēaise
Home     About     Download     Resources     Contact us    
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: -- (:)
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
end
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).

-- 
Jean-Christophe