Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Hugo Ferreira <hmf@inescporto.pt>
To: Alp Mestan <alp@mestan.fr>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Cannot safely evaluate the definition of the 	recursively-defined module
Date: Wed, 18 Mar 2009 15:56:14 +0000	[thread overview]
Message-ID: <49C1199E.3080402@inescporto.pt> (raw)
In-Reply-To: <cbe39dfc0903180548r4719fd35y9d815f23be716eca@mail.gmail.com>

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 <hmf@inescporto.pt 
> <mailto:hmf@inescporto.pt>> 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


  reply	other threads:[~2009-03-18 15:56 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-18 12:08 Hugo Ferreira
2009-03-18 12:48 ` [Caml-list] " Alp Mestan
2009-03-18 15:56   ` Hugo Ferreira [this message]
2009-03-18 16:49     ` Julien SIGNOLES
2009-03-18 17:01       ` Hugo Ferreira
2009-03-19  4:01 ` Michael Furr
2009-03-19  8:09   ` Hugo Ferreira
2009-09-25 20:06     ` Guillaume Yziquel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49C1199E.3080402@inescporto.pt \
    --to=hmf@inescporto.pt \
    --cc=alp@mestan.fr \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox