From: Hendrik Tews <tews@cs.ru.nl>
To: caml-list@inria.fr
Subject: recursive modules: Cannot safely evaluate the definition
Date: Fri, 4 Apr 2008 10:44:10 +0200 [thread overview]
Message-ID: <18421.59994.153567.662401@tandem.cs.ru.nl> (raw)
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
next reply other threads:[~2008-04-04 8:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-04 8:44 Hendrik Tews [this message]
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
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=18421.59994.153567.662401@tandem.cs.ru.nl \
--to=tews@cs.ru.nl \
--cc=caml-list@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