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.8 required=5.0 tests=AWL,SPF_SOFTFAIL, SUBJ_HAS_SPACES autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 1A8FCBBC4 for ; Wed, 18 Mar 2009 16:56:22 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkICAKu2wEnVhjEYi2dsb2JhbACNB4htAQEBCgsKBw8FIb4Pg3wG X-IronPort-AV: E=Sophos;i="4.38,385,1233529200"; d="scan'208";a="22764613" Received: from unknown (HELO ihsmtp02cons.lis.interhost.com) ([213.134.49.24]) by mail2-smtp-roc.national.inria.fr with ESMTP; 18 Mar 2009 16:56:21 +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 15:53:25 +0000 Message-ID: <49C1199E.3080402@inescporto.pt> Date: Wed, 18 Mar 2009 15:56:14 +0000 From: Hugo Ferreira User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: Alp Mestan Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Cannot safely evaluate the definition of the recursively-defined module References: <49C0E44F.6040603@inescporto.pt> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 Mar 2009 15:53:25.0377 (UTC) FILETIME=[AC1C0F10:01C9A7E1] X-Spam: no; 0.00; struct:01 struct:01 pervasives:01 elt:01 functors:01 run-time:01 compiler:01 sig:01 val:01 val:01 pervasives:01 elt:01 sig:01 beginner's:01 ocaml:01 Alp Mestan wrote: > Hi, > > replacing : > module rec A1 : AA > = struct > type q = ASet.t > type t = string > > with : > module rec A1 : AA with type q = ASet.t, type t = string > > should be okay. Shouldn't it ? > You mean? 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. R, Hugo F. > On Wed, Mar 18, 2009 at 1:08 PM, Hugo Ferreira > wrote: > > 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 ) > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > > > > -- > Alp Mestan > In charge of the C++ section on Developpez.com. > > > ------------------------------------------------------------------------ > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs