Browse thread
Cannot safely evaluate the definition of the recursively-defined module
[
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: | Julien SIGNOLES <julien.signoles@c...> |
| Subject: | Re: [Caml-list] Cannot safely evaluate the definition of the recursively-defined module |
Hello, > module rec A1 : AA with type q = ASet.t > with type t = string > = struct > type q = ASet.t > type t = string > > let compare s1 s2 = Pervasives.compare s1 s2 > let add e s = ASet.add e s > let empty = ASet.empty > end > and ASet : Set.S with type elt = A1.t > = Set.Make(A1) > > No. It doens't work. > > however I am getting the following error: > > > > Cannot safely evaluate the definition of the recursively-defined module > > (refers to "AA.empty" when implemented as a constant value) That is consistent with the behaviour specified in Section 7.8 of the reference manual [1]. Both A1 and ASet are not safe according to the definition given in this section. So a type error occurs because ocaml does know that the program won't be safely evaluated. For additional details, you could refer to the Xavier Leroy's notes describing the implementation of recursive modules in ocaml [2]. [1] http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#toc75 [2] http://caml.inria.fr/pub/papers/xleroy-recursive_modules-03.pdf Hope this helps, Julien Signoles -- Researcher-engineer CEA LIST, Software Reliability Lab 91191 Gif-Sur-Yvette Cedex tel:(+33)1.69.08.71.83 fax:(+33)1.69.08.83.95 Julien.Signoles@cea.fr