Hi, the type expression must be put between parenthesis. I think it is an error in the manual. The following works : (string, (module DEVICE)) Hashtbl.t Esther Baruk On Tue, Aug 14, 2012 at 5:11 PM, Matej Kosik < 5764c029b688c1c0d24a2e97cd764f@gmail.com> wrote: > Hello, > > In Section 7.14 of the Ocaml manual: > > http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#toc81 > > there is a `Basic example'. > > The code (with some essential fillings) may look like this: > > -------------------------------------------------- > module type DEVICE = sig type t > val foo : unit -> unit > end > let devices : (string, module DEVICE) Hashtbl.t = Hashtbl.create 17 > > module SVG = struct > type t = int > let foo _ = assert false > end > > let _ = Hashtbl.add devices "SVG" (module SVG : DEVICE) > > module PDF = struct > type t = float > let foo _ = assert false > end > > let _ = Hashtbl.add devices "PDF" (module PDF: DEVICE) > > module Device = > (val (try Hashtbl.find devices (parse_cmdline()) > with Not_found -> eprintf "Unknown device %s\n"; exit 2) > : DEVICE > ) > --------------------------------------------------- > > When I try to compile this piece of code: > > ocamlc -o main main.ml > > I get an error: > > File "main.ml", line 4, characters 23-29: > Error: Syntax error > make: *** [main] Error 2 > > Is that example sound (for Ocaml 3.12)? > Or did I spoiled something myself? > I would be grateful for any advice. Thank you in advance. > > The compiler does not seem to like giving `module DEVICE' as the second > parameter to the Hashtbl.t type constructor. I am not actually sure what > `module DEVICE' could, semantically, mean. > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > >