From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=AWL,SPF_SOFTFAIL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id C4A6ABBC4 for ; Wed, 18 Mar 2009 13:08:49 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmECAMOAwEnVhjEYjmdsb2JhbACVbQEBAQEJCwgJDwW9HYN8Bg X-IronPort-AV: E=Sophos;i="4.38,384,1233529200"; d="scan'208";a="36728470" Received: from ihsmtp02voda.lis.interhost.com (HELO ihsmtp02cons.lis.interhost.com) ([213.134.49.24]) by mail4-smtp-sop.national.inria.fr with ESMTP; 18 Mar 2009 13:08:49 +0100 Received: from [192.168.1.64] ([77.54.249.136]) by ihsmtp02cons.lis.interhost.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Mar 2009 12:05:54 +0000 Message-ID: <49C0E44F.6040603@inescporto.pt> Date: Wed, 18 Mar 2009 12:08:47 +0000 From: Hugo Ferreira User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Cannot safely evaluate the definition of the recursively-defined module Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 Mar 2009 12:05:54.0462 (UTC) FILETIME=[E387BBE0:01C9A7C1] X-Spam: no; 0.00; functors:01 run-time:01 compiler:01 sig:01 val:01 val:01 struct:01 pervasives:01 elt:01 sig:01 struct:01 beginners:01 rec:01 int:01 reuse:01 Hello, I hope this is not a beginners questions. I am trying to reuse code via functors, 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) I circumvented the problem by not using a constant value but a function instead. As I understand it this may cause run-time errors. My question is: is their any way to make the following example work. Specifically, for the example below is their any way of indicating to the compiler that AA.q = ASet.t ? TIA, Hugo F. module type AA = sig type q type t = string val compare: t -> t -> int val add: t -> q -> q val empty: unit -> q end module rec A1 : AA = 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) module type Wrap_A = sig type t type q val init: q val add: t -> q -> q end module Make_A (An_A : AA) : Wrap_A = struct type t = An_A.t type q = An_A.q (*let init = ASet.empty*) let init = An_A.empty () let add t q = An_A.add t q end module Wrap_A1 = Make_A( A1 )