From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id DAA00866; Tue, 27 Jul 2004 03:23:11 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA00216 for ; Tue, 27 Jul 2004 03:23:09 +0200 (MET DST) Received: from postman.medtronic.com (postman.medtronic.COM [144.15.157.121]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i6R1N8EV012191 for ; Tue, 27 Jul 2004 03:23:08 +0200 Received: from MSPM1BMSGH02.ent.core.medtronic.com (localhost [127.0.0.1]) by postman.medtronic.com (8.12.9/8.12.9) with ESMTP id i6R1N7bY026837 for ; Mon, 26 Jul 2004 20:23:07 -0500 (CDT) Received: from MSPM1BMSGM12.ent.core.medtronic.com ([172.24.113.180]) by MSPM1BMSGH02.ent.core.medtronic.com with Microsoft SMTPSVC(5.0.2195.5329); Mon, 26 Jul 2004 20:23:07 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: [Caml-list] Undefined_recursive_module Date: Mon, 26 Jul 2004 20:23:06 -0500 Message-ID: Thread-Topic: Undefined_recursive_module Thread-Index: AcRzeEUzOeYwTNW6Q7qNwIOYHimEqA== From: "Hawkins, Thomas" To: X-OriginalArrivalTime: 27 Jul 2004 01:23:07.0003 (UTC) FILETIME=[455A44B0:01C47378] X-Miltered: at nez-perce with ID 4105AE7C.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; snag:01 functor:01 val:01 val:01 struct:01 struct:01 elt:01 mutable:01 sig:01 sig:01 int:01 rec:01 match:02 compile:02 modules:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I just started experimenting with recursive modules, but have hit a snag = with Undefined_recursive_module. Basically I need to define an ADT where the data structure contains Sets = and the Set elements reference back to the data structure. In the = following example, the mutually recursive modules include the main data = structure (Process), an ordered type (Files), and a set (FileSet = returned from the Set functor). Both the Process and the File modules define only function values, = therefore I believe the example satisfies the "safe module" requirement. = It does compile and run for one case (see does_work). However, if I = make multiple calls to Process.add_file, Undefined_recursive_module is = raised (see does_not_work). Any suggestions? (I'm using 3.08.0) Thanks, Tom module rec Process : sig type t val create : unit -> t val add_file : File.t -> t -> unit=20 val print : t -> unit end =3D struct type t =3D { mutable files : FileSet.t } =20 let create () =3D { files =3D FileSet.empty } let add_file file process =3D process.files <- FileSet.add file process.files let print process =3D FileSet.iter File.print process.files end and File : sig type t val compare : t -> t -> int val create : Process.t -> string -> t val print : t -> unit end =3D struct type t =3D Process.t * string let compare a b =3D match a, b with (_, a), (_, b) -> String.compare a b let create process name =3D process, name let print (_, name) =3D print_string name; print_newline () end and FileSet : Set.S with type elt =3D File.t =3D Set.Make(File) ;; let does_work () =3D let p =3D Process.create () in Process.add_file (File.create p "file1") p; Process.print p ;; let does_not_work () =3D let p =3D Process.create () in Process.add_file (File.create p "file1") p; Process.add_file (File.create p "file2") p; Process.print p ;; (* does_work ();; *) does_not_work ();; ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners