* Specifying recursive modules?
@ 2008-08-20 14:31 Jérémie Lumbroso
2008-08-20 14:53 ` [Caml-list] " Martin Jambon
0 siblings, 1 reply; 2+ messages in thread
From: Jérémie Lumbroso @ 2008-08-20 14:31 UTC (permalink / raw)
To: caml-list
Hello,
I'd always thought of separating specification and definition as
simply not possible in OCaml, but OCaml's reference manual (3.10,
which is, as far as I can tell, the most recent version of the
documentation) seems to contradict my assumption:
http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#htoc100
It says that recursive specifications can be written as:
<code>
module rec <mod-name> : <mod-type> { and ... }
</code>
What does this mean? When I attempt to use this feature in the
toplevel, it results in an error:
<toplevel>
# module rec Tmp : sig
type t = Stop | Next of Tmp.t
end**;;**
Syntax error
</toplevel>
On the off-chance that OCaml might explicitly need an "and", I also
tried adding a second dummy module to the definition, but no dice ...
When I try to use this feature in a .mli/.ml file coupling, I get the
same (syntax) error. Have I misunderstood the usage? Or has this been
removed since its introduction (and the documentation not updated
accordingly)? Or is this a bug?
Jérémie
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Specifying recursive modules?
2008-08-20 14:31 Specifying recursive modules? Jérémie Lumbroso
@ 2008-08-20 14:53 ` Martin Jambon
0 siblings, 0 replies; 2+ messages in thread
From: Martin Jambon @ 2008-08-20 14:53 UTC (permalink / raw)
To: Jérémie Lumbroso; +Cc: caml-list
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1722 bytes --]
On Wed, 20 Aug 2008, Jérémie Lumbroso wrote:
> Hello,
>
> I'd always thought of separating specification and definition as
> simply not possible in OCaml, but OCaml's reference manual (3.10,
> which is, as far as I can tell, the most recent version of the
> documentation) seems to contradict my assumption:
>
> http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#htoc100
>
> It says that recursive specifications can be written as:
>
> <code>
> module rec <mod-name> : <mod-type> { and ... }
> </code>
>
> What does this mean? When I attempt to use this feature in the
> toplevel, it results in an error:
>
> <toplevel>
> # module rec Tmp : sig
> type t = Stop | Next of Tmp.t
> end**;;**
> Syntax error
> </toplevel>
This is a signature item, i.e. goes directly in a .mli file or
in the definition of a module signature:
module type X =
sig
module rec A :
sig
type t = A of B.t
end
and B :
sig
type t = B of A.t
end
end
Martin
> On the off-chance that OCaml might explicitly need an "and", I also
> tried adding a second dummy module to the definition, but no dice ...
> When I try to use this feature in a .mli/.ml file coupling, I get the
> same (syntax) error. Have I misunderstood the usage? Or has this been
> removed since its introduction (and the documentation not updated
> accordingly)? Or is this a bug?
>
> Jérémie
>
> _______________________________________________
> 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
>
--
http://mjambon.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-20 14:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-20 14:31 Specifying recursive modules? Jérémie Lumbroso
2008-08-20 14:53 ` [Caml-list] " Martin Jambon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox