Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Specifying recursive modules?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-08-20 (14:33)
From: Jérémie_Lumbroso <jeremie.lumbroso@e...>
Subject: Specifying recursive modules?

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:

It says that recursive specifications can be written as:

  module rec <mod-name> : <mod-type> { and ... }

What does this mean? When I attempt to use this feature in the
toplevel, it results in an error:

  # module rec Tmp : sig
      type t = Stop | Next of Tmp.t
  Syntax error

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?