-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify grammar & syntax (parens) of first class modules (#1949)
* Simplify grammar & syntax of first-class modules. * document and backport error for 4.02.3 package_type_of_module_type * Undeprecate `let module` + further simplify grammar. Also update the printer: insert `module` even when a UIDENT suffices to parse a Ptyp_package. Motivation: it will be super confusing for newcomers who might confuse it with a variant * Print Ptyp_package constraint in line with js formatting * add extra document for pacakge_type_of_module_type * Deprecate UIDENT Ptyp_package syntax for now. Might cause too much confusion for newcomers and people not using refmt.
- Loading branch information
1 parent
7ade7ef
commit fe79b90
Showing
7 changed files
with
4,951 additions
and
4,904 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
formatTest/unit_tests/expected_output/firstClassModules.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
module Modifier = ( | ||
val Db.Hashtbl.create(): | ||
Db.Sig with type t = Mods.t | ||
); | ||
module Modifier = ( | ||
val Db.Hashtbl.create(): | ||
Db.Sig with type t = Mods.t | ||
); | ||
module Modifier = ( | ||
val Db.Hashtbl.create(): | ||
Db.Sig with type t = Mods.t | ||
); | ||
module Modifier = ( | ||
val Db.Hashtbl.create(): | ||
Db.Sig with type t = Mods.t | ||
); | ||
module Modifier = (val Db.Hashtbl.create()); | ||
module Modifier = ( | ||
val Db.Hashtbl.create(): | ||
Db.Sig with | ||
type t = Mods.t and | ||
type s = Mods.s and | ||
type z = Mods.z | ||
); | ||
|
||
module Lowercase = (val stuff: lowercase); | ||
module Lowercase = ( | ||
val stuff: Foo.Bar.lowercase | ||
); | ||
module Lowercase = ( | ||
val stuff: | ||
Foo.Bar.lowercase with type t = Mods.t | ||
); | ||
|
||
module T = ( | ||
val (module FirstClass): myLowercaseModule | ||
); | ||
|
||
module Three = (val three: X_int); | ||
|
||
let thing: module Thing = (module MyModule); | ||
let thing: module Foo.Bar.Thing = | ||
(module MyModule); | ||
|
||
let smallThing: module lowercase = (module Mod); | ||
let smallThing: module lowercase = (module Mod); | ||
let smallThing: module Foo.Bar.lowercase = | ||
(module Mod); | ||
let smallThing: module Foo.Bar.lowercase = | ||
(module Mod); | ||
|
||
let f = (module Add: S.Z, x) => Add.add(x); | ||
|
||
let join_iter = | ||
( | ||
type ta, | ||
type tb, | ||
module A: Sig with type t = ta, | ||
module B: Sig with type t = tb, | ||
module C: Sig with type t = tb, | ||
module D: | ||
Sig with | ||
type t = tb and | ||
type s = tc and | ||
type x = td and | ||
type z = te, | ||
fn, | ||
) => | ||
fn(A.value + B.value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Modifier = (val ((Db.Hashtbl.create ()): (module Db.Sig with type t = Mods.t))); | ||
module Modifier = (val (Db.Hashtbl.create ()): (Db.Sig with type t = Mods.t)); | ||
module Modifier = (val (Db.Hashtbl.create (): module Db.Sig with type t = Mods.t)); | ||
module Modifier = (val Db.Hashtbl.create (): Db.Sig with type t = Mods.t); | ||
module Modifier = (val Db.Hashtbl.create ()); | ||
module Modifier = (val Db.Hashtbl.create (): | ||
Db.Sig with type t = Mods.t and type s = Mods.s and | ||
type z = Mods.z); | ||
|
||
module Lowercase = (val stuff: lowercase); | ||
module Lowercase = (val stuff: Foo.Bar.lowercase); | ||
module Lowercase = (val stuff: Foo.Bar.lowercase with type t = Mods.t); | ||
|
||
module T = (val (module FirstClass): myLowercaseModule); | ||
|
||
module Three = (val three: X_int); | ||
|
||
let thing: module Thing = (module MyModule); | ||
let thing: module Foo.Bar.Thing = (module MyModule); | ||
|
||
let smallThing: (module lowercase) = (module Mod); | ||
let smallThing: module lowercase = (module Mod); | ||
let smallThing: (module Foo.Bar.lowercase) = (module Mod); | ||
let smallThing: module Foo.Bar.lowercase = (module Mod); | ||
|
||
let f = ((module Add : S.Z), x) => Add.add(x); | ||
|
||
let join_iter = | ||
(type ta, type tb, | ||
((module A): (module Sig with type t=ta)), | ||
(module B): (module Sig with type t=tb), | ||
module C: module Sig with type t=tb, | ||
module D: Sig with type t=tb and type s =tc and type x = td and type z = te, | ||
fn) => fn(A.value + B.value); |
Oops, something went wrong.