Reason: Simplify grammar package type constraint on let bindings

Created on 20 May 2018  路  2Comments  路  Source: reasonml/reason

/* before */
let thing: (module Thing) = (module MyModule);

/* after */
let thing: Thing = (module MyModule);

Idea: the (module Thing) package type constraint syntax looks very foreign. Since modules are usually associated with an uppercase-cased first letter identifier, the package type constraint syntax can probably be simplified to just using the uppercase-cased first letter identifier (with possible dot for submodules).

The grammar needs to be a little bit restructured to make this work. Currently module types can be lower cased too, (module thing) is legal Ocaml for some reason, resulting in a reduce/reduce conflict.

/* ambiguity */
let thing: foo = (module Thing);
/* is foo a module type or is it a core_type */

By special casing this case to accept uppercase identifiers in the module type case, the grammar could possibly allow parsing of let thing: Thing = (module MyModule); without too much trouble.

FEATURE REQUEST Parser

Most helpful comment

I might have been prematurely excited by finding something that did not lead to a shift/reduce conflict in the current grammar. 馃槄Yes, it might will be confusing for newcomers. They already have a lot of stuff to learn. It's better to at least parse the "short form" and print the module keyword with refmt.

All 2 comments

I'm kinda suspecting that newcomers would accidentally mistake that type for a variant or something. Happens often enough in other cases. Like, how would you explain this feature? (Actually asking. Maybe it's not that confusing?)

I might have been prematurely excited by finding something that did not lead to a shift/reduce conflict in the current grammar. 馃槄Yes, it might will be confusing for newcomers. They already have a lot of stuff to learn. It's better to at least parse the "short form" and print the module keyword with refmt.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TrakBit picture TrakBit  路  3Comments

bluddy picture bluddy  路  3Comments

rickyvetter picture rickyvetter  路  4Comments

jberdine picture jberdine  路  3Comments

rickyvetter picture rickyvetter  路  3Comments