From: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com>
To: caml-list@inria.fr
Subject: [Caml-list] Section 7.14: First-class modules
Date: Tue, 14 Aug 2012 16:11:54 +0100 [thread overview]
Message-ID: <502A6ABA.4070600@gmail.com> (raw)
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.
next reply other threads:[~2012-08-14 15:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-14 15:11 Matej Kosik [this message]
2012-08-14 15:28 ` Esther Baruk
2012-08-14 19:59 ` Matej Kosik
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=502A6ABA.4070600@gmail.com \
--to=5764c029b688c1c0d24a2e97cd764f@gmail.com \
--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