caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] First class module syntax
@ 2017-05-05 12:28 Andre Nathan
  2017-05-05 12:42 ` octachron
  0 siblings, 1 reply; 5+ messages in thread
From: Andre Nathan @ 2017-05-05 12:28 UTC (permalink / raw)
  To: caml-list


[-- Attachment #1.1: Type: text/plain, Size: 437 bytes --]

Hi

I was thinking about the syntax for a function taking a module as a
parameter, i.e.,

  let f (module M : S) = ...

Off the top of my head I couldn't think of anything that would prevent
the syntax from being like

  let f (M : S) = ...

I can't think of ways in which this would be ambiguously parsed, so I
was just wondering what led to the choice of requiring the "module"
keyword in this case.

Cheers,
Andre


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] First class module syntax
  2017-05-05 12:28 [Caml-list] First class module syntax Andre Nathan
@ 2017-05-05 12:42 ` octachron
  2017-05-05 12:54   ` Andre Nathan
  0 siblings, 1 reply; 5+ messages in thread
From: octachron @ 2017-05-05 12:42 UTC (permalink / raw)
  To: caml-list

As a counter-example, consider:

     module type s = sig end (* module type names do not need to start 
with a capital *)
     type s = M

Then,  both

     (* f: s → unit *)
     let f (M:s) = ()

and

     (* g: (module s) → unit *)
     let g (module M:s) = ()

are currently valid.

Consequently, allowing "g:(module s)→unit" to be written as

     let g (M:s) = ()

would be ambiguous.

— octachron.

Le 05/05/2017 à 14:28, Andre Nathan a écrit :
> Hi
>
> I was thinking about the syntax for a function taking a module as a
> parameter, i.e.,
>
>    let f (module M : S) = ...
>
> Off the top of my head I couldn't think of anything that would prevent
> the syntax from being like
>
>    let f (M : S) = ...
>
> I can't think of ways in which this would be ambiguously parsed, so I
> was just wondering what led to the choice of requiring the "module"
> keyword in this case.
>
> Cheers,
> Andre
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] First class module syntax
  2017-05-05 12:42 ` octachron
@ 2017-05-05 12:54   ` Andre Nathan
  2017-05-05 13:08     ` Max Mouratov
  0 siblings, 1 reply; 5+ messages in thread
From: Andre Nathan @ 2017-05-05 12:54 UTC (permalink / raw)
  To: caml-list


[-- Attachment #1.1: Type: text/plain, Size: 148 bytes --]

On 05/05/2017 09:42 AM, octachron wrote:
(* module type names do not need to start with a capital *)

I didn't know that!

Thanks,
Andre



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] First class module syntax
  2017-05-05 12:54   ` Andre Nathan
@ 2017-05-05 13:08     ` Max Mouratov
  2017-05-06  8:00       ` SP
  0 siblings, 1 reply; 5+ messages in thread
From: Max Mouratov @ 2017-05-05 13:08 UTC (permalink / raw)
  To: Andre Nathan; +Cc: caml-list

Friday, May 5, 2017, 5:54:27 PM, Andre wrote:
>> On 05/05/2017 09:42 AM, octachron wrote:
>> (* module type names do not need to start with a capital *)
>
> I didn't know that!

Wow, I didn't know that as well! Quite surprising.

According to docs, module type names are the only kind of identifiers
that can be either capitalized or not [1]. Why is it so? What is
rationale for this design decision? I'm really curious.

[1] https://caml.inria.fr/pub/docs/manual-ocaml/names.html#modtype-name


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Caml-list] First class module syntax
  2017-05-05 13:08     ` Max Mouratov
@ 2017-05-06  8:00       ` SP
  0 siblings, 0 replies; 5+ messages in thread
From: SP @ 2017-05-06  8:00 UTC (permalink / raw)
  To: caml-list

On 05/05/2017 14:08, Max Mouratov wrote:
> According to docs, module type names are the only kind of identifiers
> that can be either capitalized or not [1]. Why is it so? What is
> rationale for this design decision? I'm really curious.

Exceptions are the spice of life :P

-- 
    SP

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-06  8:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 12:28 [Caml-list] First class module syntax Andre Nathan
2017-05-05 12:42 ` octachron
2017-05-05 12:54   ` Andre Nathan
2017-05-05 13:08     ` Max Mouratov
2017-05-06  8:00       ` SP

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).