caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* recursive modules: Cannot safely evaluate the definition
@ 2008-04-04  8:44 Hendrik Tews
  2008-04-04  9:00 ` [Caml-list] " Keiko Nakata
  0 siblings, 1 reply; 6+ messages in thread
From: Hendrik Tews @ 2008-04-04  8:44 UTC (permalink / raw)
  To: caml-list

Hi,

for the following program

    module type Result_sig = sig
      val result : int
    end

    module type Build_sig = sig
      val compute : int -> unit
    end

    module rec Rec : functor(Arg : Result_sig) -> Build_sig = 
      functor(Arg : Result_sig) ->
    struct
      let compute = function
	| 0 -> Printf.printf "result: %d\n" Arg.result
	| n ->
	    let module Arg_x_2 = struct
	      let result = Arg.result * 2
	    end
	    in
	    let module Rec_tail = Rec(Arg_x_2)
	    in
	      Rec_tail.compute (n-1)
    end


I get the compiler error 

  Cannot safely evaluate the definition of the recursively-defined module Rec

Could somebody explain to me why? As far as I can see, module Rec
is safe in the sense of section 7.9 of the reference manual. 

[Background: I am trying to solve the following Ocaml puzzle:
Build a (nested) functor application, where the functors applied
depend on an input value of the program. In particular the depth
of the functor application depends on the input value and could
be arbitrary high.]


Bye,

Hendrik


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-04-04 16:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-04  8:44 recursive modules: Cannot safely evaluate the definition Hendrik Tews
2008-04-04  9:00 ` [Caml-list] " Keiko Nakata
2008-04-04 12:44   ` Jean-Christophe Filliâtre
2008-04-04 15:23     ` Hendrik Tews
2008-04-04 15:45       ` Keiko Nakata
2008-04-04 16:17         ` Sebastien Ferre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).