From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p2Q7a6V2023128 for ; Sat, 26 Mar 2011 08:36:06 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4AAMGWjU3Y5v4vmWdsb2JhbAClYRQBAQEBAQYNCwcUJcJjhWkEhTiHPYNUGg X-IronPort-AV: E=Sophos;i="4.63,247,1299452400"; d="scan'208";a="103684322" Received: from amout07.alpha-mail.net ([216.230.254.47]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Mar 2011 08:36:01 +0100 Received: from webarc04.alpha-mail.jp (webarc04 [216.230.254.84]) by amout07.alpha-mail.net with ESMTP id p2Q7Zvgo027935; Sat, 26 Mar 2011 16:35:57 +0900 X-Virus-Scanned: amavisd-new at Alpha-Mail Out Received: from ltsub02.alpha-mail.net (unknown [216.230.254.30]) by webarc04.alpha-mail.jp (Postfix) with ESMTP id 3E8821C080CB; Sat, 26 Mar 2011 16:35:52 +0900 (JST) Received: from [192.168.0.100] (196.62.205.61.west.global.alpha-net.ne.jp [61.205.62.196]) by ltsub02.alpha-mail.net (Alpha-mail) with ESMTP id 95B2A746004C; Sat, 26 Mar 2011 16:35:56 +0900 (JST) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Satoshi Ogasawara In-Reply-To: <083A0142-982A-42DA-84EB-E3F5D26577E1@gmail.com> Date: Sat, 26 Mar 2011 16:35:51 +0900 Cc: Joel Reymont Message-Id: <7520C389-9398-479A-8310-792DDCBCADEB@itpl.co.jp> References: <083A0142-982A-42DA-84EB-E3F5D26577E1@gmail.com> To: caml-list X-Pgp-Agent: GPGMail 1.3.3 X-Mailer: Apple Mail (2.1084) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p2Q7a6V2023128 Subject: [Caml-list] Re: shortcut to omit the functor keyword -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 2011/03/26, at 3:43, Joel Reymont wrote: > Why does the shortcut to omit the functor keyword only exists in module definitions but not in signatures? > > For example, why do > > module type A = sig end;; > module type B = sig end;; > > module type C = functor (X : A) -> functor (Y : B) -> sig end;; > > and not > > module type C (X : A) (Y : B) = sig end;; I'd like to suggest yet another grammar. module type C = functor (X : A) (Y : B) -> sig end;; Here is a camlp4 code. - ---- open Camlp4.PreCast module Caml = Syntax let expand_module_type_functor_args _loc args mt = List.fold_left (fun mt (i, t) -> <:module_type< functor ( $i$ : $t$ ) -> $mt$ >>) mt (List.rev args) EXTEND Caml.Gram GLOBAL: Caml.expr; Caml.str_item: LEVEL "top" [ [ "module"; "type"; i = Caml.a_UIDENT; "="; "functor"; args = LIST1 functor_arg; "->"; mt = Caml.module_type -> <:str_item< module type $i$ = $expand_module_type_functor_args _loc args mt$ >> ] ]; functor_arg : [ [ "("; i = Caml.a_UIDENT; ":"; t = Caml.module_type; ")" -> (i, t) ] ]; END;; - ---- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) iEYEARECAAYFAk2Nl1cACgkQzTChtNfYLwa3lgCgl20db1FmDwhUyABil1eEAXj9 kVMAoPGI7ercFu6JX9t0Ev/bl3fWIvax =a0Fh -----END PGP SIGNATURE-----