Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Satoshi Ogasawara <ogasawara@itpl.co.jp>
To: caml-list <caml-list@inria.fr>
Cc: Joel Reymont <joelr1@gmail.com>
Subject: [Caml-list] Re: shortcut to omit the functor keyword
Date: Sat, 26 Mar 2011 16:35:51 +0900	[thread overview]
Message-ID: <7520C389-9398-479A-8310-792DDCBCADEB@itpl.co.jp> (raw)
In-Reply-To: <083A0142-982A-42DA-84EB-E3F5D26577E1@gmail.com>

-----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-----


      parent reply	other threads:[~2011-03-26  7:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-25 18:43 [Caml-list] " Joel Reymont
2011-03-25 19:10 ` Vincent Aravantinos
2011-03-25 19:11 ` Andreas Rossberg
2011-03-26  7:35 ` Satoshi Ogasawara [this message]

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=7520C389-9398-479A-8310-792DDCBCADEB@itpl.co.jp \
    --to=ogasawara@itpl.co.jp \
    --cc=caml-list@inria.fr \
    --cc=joelr1@gmail.com \
    /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