Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify grammar & syntax (parens) of first class modules #1949

Merged
merged 6 commits into from
Jun 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions formatTest/unit_tests/expected_output/firstClassModules.re
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);
31 changes: 14 additions & 17 deletions formatTest/unit_tests/expected_output/modules.re
Original file line number Diff line number Diff line change
Expand Up @@ -483,24 +483,24 @@ module MyModule = {
let x = 10;
};

let myFirstClass: (module HasInt) =
let myFirstClass: module HasInt =
(module MyModule);

let myFirstClassWillBeFormattedAs: (module HasInt) =
let myFirstClassWillBeFormattedAs: module HasInt =
(module MyModule);

let acceptsAndUnpacksFirstClass =
((module M: HasInt)) =>
(module M: HasInt) =>
M.x + M.x;

let acceptsAndUnpacksFirstClass =
((module M: HasInt)) =>
(module M: HasInt) =>
M.x + M.x;

module SecondClass = (val myFirstClass);

module SecondClass2 = (
val ((module MyModule): (module HasInt))
val (module MyModule): HasInt
);

let p = SecondClass.x;
Expand Down Expand Up @@ -593,21 +593,18 @@ module X = [%test extension];
module type T = [%test extension];

let foo =
(type a, (module X: X_t with type t = a)) => X.a;
(type a, module X: X_t with type t = a) => X.a;

let f =
(
(module M: M with type x = x and type y = y),
) => M.x;
(module M: M with type x = x and type y = y) => M.x;

let foo =
(
(module X
: X_t with
type t = a and
type s = a and
type z = a
),
(module Y: Y_t with type t = a),
(module Z: Z_t with type t = a),
module X:
X_t with
type t = a and
type s = a and
type z = a,
module Y: Y_t with type t = a,
module Z: Z_t with type t = a,
) => X.a;
16 changes: 7 additions & 9 deletions formatTest/unit_tests/expected_output/modules_no_semi.re
Original file line number Diff line number Diff line change
Expand Up @@ -483,24 +483,24 @@ module MyModule = {
let x = 10;
};

let myFirstClass: (module HasInt) =
let myFirstClass: module HasInt =
(module MyModule);

let myFirstClassWillBeFormattedAs: (module HasInt) =
let myFirstClassWillBeFormattedAs: module HasInt =
(module MyModule);

let acceptsAndUnpacksFirstClass =
((module M: HasInt)) =>
(module M: HasInt) =>
M.x + M.x;

let acceptsAndUnpacksFirstClass =
((module M: HasInt)) =>
(module M: HasInt) =>
M.x + M.x;

module SecondClass = (val myFirstClass);

module SecondClass2 = (
val ((module MyModule): (module HasInt))
val (module MyModule): HasInt
);

let p = SecondClass.x;
Expand Down Expand Up @@ -593,9 +593,7 @@ module X = [%test extension];
module type T = [%test extension];

let foo =
(type a, (module X: X_t with type t = a)) => X.a;
(type a, module X: X_t with type t = a) => X.a;

let f =
(
(module M: M with type x = x and type y = y),
) => M.x;
(module M: M with type x = x and type y = y) => M.x;
34 changes: 34 additions & 0 deletions formatTest/unit_tests/input/firstClassModules.re
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);
Loading