From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <5764c029b688c1c0d24a2e97cd764f@gmail.com> X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id DAEBF7ED67 for ; Tue, 14 Aug 2012 17:11:55 +0200 (CEST) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of 5764c029b688c1c0d24a2e97cd764f@gmail.com) identity=pra; client-ip=74.125.83.54; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="5764c029b688c1c0d24a2e97cd764f@gmail.com"; x-sender="5764c029b688c1c0d24a2e97cd764f@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of 5764c029b688c1c0d24a2e97cd764f@gmail.com designates 74.125.83.54 as permitted sender) identity=mailfrom; client-ip=74.125.83.54; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="5764c029b688c1c0d24a2e97cd764f@gmail.com"; x-sender="5764c029b688c1c0d24a2e97cd764f@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ee0-f54.google.com) identity=helo; client-ip=74.125.83.54; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="5764c029b688c1c0d24a2e97cd764f@gmail.com"; x-sender="postmaster@mail-ee0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtQHAGtpKlBKfVM2k2dsb2JhbABEgiQEg1mzGQRrCCIBAQEBCQkLCRQEI4I5Ag8EGQEbHAIDEhAPAgUWCwILAwIBAgEREQEFAS8IAh6HWwEDDAQHlwSCYQkDi1RPgnKFdgoZJw1XiHEBBQyBFYoYgmGCCoESA5VLgRSESIhXPoN/ X-IronPort-AV: E=Sophos;i="4.77,766,1336341600"; d="scan'208";a="153063435" Received: from mail-ee0-f54.google.com ([74.125.83.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 14 Aug 2012 17:11:55 +0200 Received: by eeke52 with SMTP id e52so238957eek.27 for ; Tue, 14 Aug 2012 08:11:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type:content-transfer-encoding; bh=58DYNo9WDEnaMtzQsykPrgXLRaBI9gSSiMIGNfJDvdg=; b=tfdwlRUcGMlwPnaMiO+X4IAxXSWSryGiEpqu7NGV1IQxP7UjszQxmZmNDXRbFzpfj3 K7k9Bm1RuPR8CGFUDnz6C6Il+DVi/hPkj7kOzzH550zE9ikIgWptIjHvJcJKB3In2kwS UqCwnog0NoMiKHDP9ZzVEWvYqGeCYYEmrZYn+DRUvCDZy6LyfOeHvIULevzrzRdIftBz oHeXjb1Trte1VRLgvWf992JpyPopCeoeZlP4CkwYxv55e3F66eB4kUN2J+hdNsBnnsrt sdXqZG1TMKRryPrGJo9IlysOGs+rPvN9WiDuRlbTUaEaoNqOwN/zWzDy2fcJCAE91LAP xiZw== Received: by 10.14.175.8 with SMTP id y8mr15631855eel.8.1344957115045; Tue, 14 Aug 2012 08:11:55 -0700 (PDT) Received: from [172.27.6.213] ([213.106.240.92]) by mx.google.com with ESMTPS id d48sm7621665eeo.10.2012.08.14.08.11.53 (version=SSLv3 cipher=OTHER); Tue, 14 Aug 2012 08:11:54 -0700 (PDT) Message-ID: <502A6ABA.4070600@gmail.com> Date: Tue, 14 Aug 2012 16:11:54 +0100 From: Matej Kosik <5764c029b688c1c0d24a2e97cd764f@gmail.com> User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4 MIME-Version: 1.0 To: caml-list@inria.fr X-Enigmail-Version: 1.4.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Caml-list] Section 7.14: First-class modules 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.