diff --git a/changes/locally-abstract-let-format.fix.md b/changes/locally-abstract-let-format.fix.md new file mode 100644 index 0000000000..e417bacc4f --- /dev/null +++ b/changes/locally-abstract-let-format.fix.md @@ -0,0 +1 @@ +- The formatter keeps `let f: type a. t => a = x =>` on one line when it fits, instead of breaking after `:` and `=` whenever the body spans several lines. diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 9d571f0adf..9a7f3e195b 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -2494,27 +2494,55 @@ and print_value_binding ~state ~rec_flag (vb : Parsetree.value_binding) cmt_tbl print_comments (print_ident_like txt) cmt_tbl loc) pvc_newtypes) in - Doc.group - (Doc.concat - [ - attrs; - header; - print_pattern ~state pattern cmt_tbl; - Doc.text ":"; - Doc.indent - (Doc.concat - [ - Doc.line; - Doc.text "type "; - newtypes; - Doc.dot; - Doc.space; - print_typ_expr ~state pvc_type cmt_tbl; - Doc.text " ="; - Doc.line; - print_expression_with_comments_and_parens ~state expr cmt_tbl; - ]); - ]) + let pattern_doc = print_pattern ~state pattern cmt_tbl in + let typ_doc = print_typ_expr ~state pvc_type cmt_tbl in + let expr_doc = + print_expression_with_comments_and_parens ~state expr cmt_tbl + in + (* Keep `let f: type a. t = body` on one line up to the body's first + line break when it fits; otherwise break after `:` and `=`. The + attributes stay outside, so that [fits] measures from the `let`. *) + Doc.concat + [ + attrs; + Doc.custom_layout + [ + (* not a group: a group would be marked broken by the body's line + breaks, and [fits] would then accept a header that overflows *) + Doc.concat + [ + header; + pattern_doc; + Doc.text ": type "; + newtypes; + Doc.dot; + Doc.space; + typ_doc; + Doc.text " = "; + expr_doc; + ]; + Doc.group + (Doc.concat + [ + header; + pattern_doc; + Doc.text ":"; + Doc.indent + (Doc.concat + [ + Doc.line; + Doc.text "type "; + newtypes; + Doc.dot; + Doc.space; + typ_doc; + Doc.text " ="; + Doc.line; + expr_doc; + ]); + ]); + ]; + ] | { pvb_pat = { diff --git a/tests/syntax_tests/data/printer/expr/expected/newtype.res.txt b/tests/syntax_tests/data/printer/expr/expected/newtype.res.txt index e8480471a6..b0c49a6af1 100644 --- a/tests/syntax_tests/data/printer/expr/expected/newtype.res.txt +++ b/tests/syntax_tests/data/printer/expr/expected/newtype.res.txt @@ -26,6 +26,32 @@ let cancel_and_collect_callbacks: 'a 'u 'c. (list, promise<'a, 'u, 'c>) => list = (type x, callbacks_accumulator, p: promise<_, _, c>) => () +// the header stays on one line when it fits +let rec eval: type a. expr => a = e => + switch e { + | Int(n) => n + | Bool(b) => b + } + +let id: type a. a => a = x => x + +/** Docs */ +@inline +let rec veryLongFunctionNameForWrapping: + type a b c. (someLongType, anotherLongType) => resultType = + (x, y) => + switch x { + | _ => 1 + } + +module M = { + let default: type a. ty => a = ty => + switch ty { + | TInt => 0 + | TString => "" + } +} + // type parameters written between term parameters are hoisted to the front let g = (type t, x, y: t) => y let g = (@attr type t u v, x: int, y: t, z: v) => (y, z) diff --git a/tests/syntax_tests/data/printer/expr/newtype.res b/tests/syntax_tests/data/printer/expr/newtype.res index a5b6b62eba..da5bc605e2 100644 --- a/tests/syntax_tests/data/printer/expr/newtype.res +++ b/tests/syntax_tests/data/printer/expr/newtype.res @@ -21,6 +21,32 @@ let cancel_and_collect_callbacks: = (type x, callbacks_accumulator, p: promise<_, _, c>) => (); +// the header stays on one line when it fits +let rec eval: + type a. expr => a = + e => + switch e { + | Int(n) => n + | Bool(b) => b + } + +let id: type a. a => a = x => x + +/** Docs */ +@inline +let rec veryLongFunctionNameForWrapping: type a b c. (someLongType, anotherLongType) => resultType = (x, y) => + switch x { + | _ => 1 + } + +module M = { + let default: type a. ty => a = ty => + switch ty { + | TInt => 0 + | TString => "" + } +} + // type parameters written between term parameters are hoisted to the front let g = (x, type t, y: t) => y let g = (x: int, @attr type t u, y: t, type v, z: v) => (y, z) diff --git a/tests/tests/src/extensible_variant_test.mjs b/tests/tests/src/extensible_variant_test.mjs index 15e36b1c2a..6ffc3b8bda 100644 --- a/tests/tests/src/extensible_variant_test.mjs +++ b/tests/tests/src/extensible_variant_test.mjs @@ -89,17 +89,17 @@ function makeException() { } Mocha.describe("Extensible_variant_test", () => { - Mocha.test("test_int", () => Test_utils.eq("File \"extensible_variant_test.res\", line 73, characters 7-14", 3, to_int({ + Mocha.test("test_int", () => Test_utils.eq("File \"extensible_variant_test.res\", line 71, characters 7-14", 3, to_int({ RE_EXN_ID: Int, _1: 3, _2: 0 }))); - Mocha.test("test_int2", () => Test_utils.eq("File \"extensible_variant_test.res\", line 77, characters 7-14", 0, to_int({ + Mocha.test("test_int2", () => Test_utils.eq("File \"extensible_variant_test.res\", line 75, characters 7-14", 0, to_int({ RE_EXN_ID: Int$1, _1: 3, _2: 0 }))); - Mocha.test("test_string", () => Test_utils.eq("File \"extensible_variant_test.res\", line 81, characters 7-14", -1, to_int({ + Mocha.test("test_string", () => Test_utils.eq("File \"extensible_variant_test.res\", line 79, characters 7-14", -1, to_int({ RE_EXN_ID: Str, _1: "x" }))); @@ -109,15 +109,15 @@ Mocha.describe("Extensible_variant_test", () => { "x-coord": 1, y: 2 }; - Test_utils.eq("File \"extensible_variant_test.res\", line 86, characters 7-14", 1, point["x-coord"]); - Test_utils.eq("File \"extensible_variant_test.res\", line 88, characters 6-13", 3, Point === Point ? 3 : 0); + Test_utils.eq("File \"extensible_variant_test.res\", line 84, characters 7-14", 1, point["x-coord"]); + Test_utils.eq("File \"extensible_variant_test.res\", line 86, characters 6-13", 3, Point === Point ? 3 : 0); }); Mocha.test("rebind", () => { - Test_utils.eq("File \"extensible_variant_test.res\", line 98, characters 7-14", -1, to_int({ + Test_utils.eq("File \"extensible_variant_test.res\", line 96, characters 7-14", -1, to_int({ RE_EXN_ID: Str, _1: "x" })); - Test_utils.eq("File \"extensible_variant_test.res\", line 99, characters 7-14", true, Primitive_object.equal({ + Test_utils.eq("File \"extensible_variant_test.res\", line 97, characters 7-14", true, Primitive_object.equal({ RE_EXN_ID: Str, _1: "x" }, { @@ -126,18 +126,18 @@ Mocha.describe("Extensible_variant_test", () => { })); }); Mocha.test("indexed extension", () => { - Test_utils.eq("File \"extensible_variant_test.res\", line 103, characters 7-14", 0, defaultOf({ + Test_utils.eq("File \"extensible_variant_test.res\", line 101, characters 7-14", 0, defaultOf({ RE_EXN_ID: IntKey })); - Test_utils.eq("File \"extensible_variant_test.res\", line 104, characters 7-14", "", defaultOf({ + Test_utils.eq("File \"extensible_variant_test.res\", line 102, characters 7-14", "", defaultOf({ RE_EXN_ID: StringKey })); }); Mocha.test("private extensible", () => { - Test_utils.eq("File \"extensible_variant_test.res\", line 108, characters 7-14", "A", privateName({ + Test_utils.eq("File \"extensible_variant_test.res\", line 106, characters 7-14", "A", privateName({ RE_EXN_ID: A })); - Test_utils.eq("File \"extensible_variant_test.res\", line 109, characters 7-14", "other", privateName(b)); + Test_utils.eq("File \"extensible_variant_test.res\", line 107, characters 7-14", "other", privateName(b)); }); Mocha.test("local exceptions are generative", () => { let match = makeException(); @@ -149,10 +149,10 @@ Mocha.describe("Extensible_variant_test", () => { caught = Primitive_exceptions.internalToException(raw_exn); } if (caught !== undefined) { - Test_utils.eq("File \"extensible_variant_test.res\", line 120, characters 9-16", true, match[1](caught)); - return Test_utils.eq("File \"extensible_variant_test.res\", line 121, characters 9-16", false, match$1[1](caught)); + Test_utils.eq("File \"extensible_variant_test.res\", line 118, characters 9-16", true, match[1](caught)); + return Test_utils.eq("File \"extensible_variant_test.res\", line 119, characters 9-16", false, match$1[1](caught)); } else { - return Test_utils.ok("File \"extensible_variant_test.res\", line 122, characters 17-24", false); + return Test_utils.ok("File \"extensible_variant_test.res\", line 120, characters 17-24", false); } }); }); diff --git a/tests/tests/src/extensible_variant_test.res b/tests/tests/src/extensible_variant_test.res index 72851d73c9..9246c6aea3 100644 --- a/tests/tests/src/extensible_variant_test.res +++ b/tests/tests/src/extensible_variant_test.res @@ -30,14 +30,12 @@ type key<_> = .. type key<_> += IntKey: key type key<_> += StringKey: key -let defaultOf: - type a. key => option = - key => - switch key { - | IntKey => Some(0) - | StringKey => Some("") - | _ => None - } +let defaultOf: type a. key => option = key => + switch key { + | IntKey => Some(0) + | StringKey => Some("") + | _ => None + } // Outside code can match a private extensible type but not extend it. module Private: { diff --git a/tests/tests/src/gadt_test.mjs b/tests/tests/src/gadt_test.mjs index bf4d137b0a..0e6d9b8635 100644 --- a/tests/tests/src/gadt_test.mjs +++ b/tests/tests/src/gadt_test.mjs @@ -231,7 +231,7 @@ function depth(n) { Mocha.describe("Gadt_test", () => { Mocha.test("evaluator", () => { - Test_utils.eq("File \"gadt_test.res\", line 203, characters 7-14", 10, $$eval({ + Test_utils.eq("File \"gadt_test.res\", line 187, characters 7-14", 10, $$eval({ TAG: "If", _0: { TAG: "Equal", @@ -260,7 +260,7 @@ Mocha.describe("Gadt_test", () => { _0: 20 } })); - Test_utils.eq("File \"gadt_test.res\", line 204, characters 7-14", true, $$eval({ + Test_utils.eq("File \"gadt_test.res\", line 188, characters 7-14", true, $$eval({ TAG: "First", _0: { TAG: "Pair", @@ -274,7 +274,7 @@ Mocha.describe("Gadt_test", () => { } } })); - Test_utils.eq("File \"gadt_test.res\", line 205, characters 7-14", [ + Test_utils.eq("File \"gadt_test.res\", line 189, characters 7-14", [ 3, false ], $$eval({ @@ -304,7 +304,7 @@ Mocha.describe("Gadt_test", () => { })); }); Mocha.test("type witnesses", () => { - Test_utils.eq("File \"gadt_test.res\", line 210, characters 6-13", `(1, "a")::(2, "b")::[]`, show({ + Test_utils.eq("File \"gadt_test.res\", line 194, characters 6-13", `(1, "a")::(2, "b")::[]`, show({ TAG: "TList", _0: { TAG: "TPair", @@ -318,29 +318,29 @@ Mocha.describe("Gadt_test", () => { 2, "b" ], tl: /* [] */0}})); - Test_utils.eq("File \"gadt_test.res\", line 214, characters 7-14", "Some(None)", show({ + Test_utils.eq("File \"gadt_test.res\", line 198, characters 7-14", "Some(None)", show({ TAG: "TOption", _0: { TAG: "TOption", _0: "TInt" } }, Primitive_option.some(undefined))); - Test_utils.eq("File \"gadt_test.res\", line 215, characters 7-14", 0, 0); - Test_utils.eq("File \"gadt_test.res\", line 216, characters 7-14", "", ""); - Test_utils.eq("File \"gadt_test.res\", line 217, characters 7-14", /* [] */0, /* [] */0); - Test_utils.eq("File \"gadt_test.res\", line 218, characters 7-14", undefined, undefined); - Test_utils.eq("File \"gadt_test.res\", line 219, characters 7-14", "int", "int"); + Test_utils.eq("File \"gadt_test.res\", line 199, characters 7-14", 0, 0); + Test_utils.eq("File \"gadt_test.res\", line 200, characters 7-14", "", ""); + Test_utils.eq("File \"gadt_test.res\", line 201, characters 7-14", /* [] */0, /* [] */0); + Test_utils.eq("File \"gadt_test.res\", line 202, characters 7-14", undefined, undefined); + Test_utils.eq("File \"gadt_test.res\", line 203, characters 7-14", "int", "int"); }); Mocha.test("equality witness", () => { - Test_utils.eq("File \"gadt_test.res\", line 223, characters 7-14", 42, 42); - Test_utils.ok("File \"gadt_test.res\", line 224, characters 7-14", equalTy({ + Test_utils.eq("File \"gadt_test.res\", line 207, characters 7-14", 42, 42); + Test_utils.ok("File \"gadt_test.res\", line 208, characters 7-14", equalTy({ TAG: "TList", _0: "TInt" }, { TAG: "TList", _0: "TInt" }) !== undefined); - Test_utils.ok("File \"gadt_test.res\", line 225, characters 7-14", equalTy({ + Test_utils.ok("File \"gadt_test.res\", line 209, characters 7-14", equalTy({ TAG: "TPair", _0: "TInt", _1: "TString" @@ -371,12 +371,12 @@ Mocha.describe("Gadt_test", () => { _1: {hd: 1, tl: {hd: 2, tl: /* [] */0}} } ]; - Test_utils.eq("File \"gadt_test.res\", line 230, characters 7-14", [ + Test_utils.eq("File \"gadt_test.res\", line 214, characters 7-14", [ 1, undefined, undefined ], values.map(v => fromDynamic("TInt", v))); - Test_utils.eq("File \"gadt_test.res\", line 231, characters 7-14", [ + Test_utils.eq("File \"gadt_test.res\", line 215, characters 7-14", [ undefined, undefined, {hd: 1, tl: {hd: 2, tl: /* [] */0}} @@ -384,7 +384,7 @@ Mocha.describe("Gadt_test", () => { TAG: "TList", _0: "TInt" }, v))); - Test_utils.eq("File \"gadt_test.res\", line 233, characters 6-13", [ + Test_utils.eq("File \"gadt_test.res\", line 217, characters 6-13", [ "1", "s" ], showAll([ @@ -399,13 +399,13 @@ Mocha.describe("Gadt_test", () => { show: s => s } ])); - Test_utils.eq("File \"gadt_test.res\", line 240, characters 7-14", "7", showBoxed({ + Test_utils.eq("File \"gadt_test.res\", line 224, characters 7-14", "7", showBoxed({ TAG: "Boxed", _0: ShowInt, _1: 7 })); }); - Mocha.test("typed printf", () => Test_utils.eq("File \"gadt_test.res\", line 244, characters 7-14", "x=1, y=b", format({ + Mocha.test("typed printf", () => Test_utils.eq("File \"gadt_test.res\", line 228, characters 7-14", "x=1, y=b", format({ TAG: "Text", _0: "x=", _1: { @@ -421,28 +421,28 @@ Mocha.describe("Gadt_test", () => { } }, "")(1)("b"))); Mocha.test("representation attributes", () => { - Test_utils.eq("File \"gadt_test.res\", line 248, characters 7-14", 3, 3); - Test_utils.eq("File \"gadt_test.res\", line 249, characters 7-14", "s", "s"); - Test_utils.eq("File \"gadt_test.res\", line 250, characters 7-14", { + Test_utils.eq("File \"gadt_test.res\", line 232, characters 7-14", 3, 3); + Test_utils.eq("File \"gadt_test.res\", line 233, characters 7-14", "s", "s"); + Test_utils.eq("File \"gadt_test.res\", line 234, characters 7-14", { TAG: "int", v: 3 }, { TAG: "int", v: 3 }); - Test_utils.eq("File \"gadt_test.res\", line 251, characters 7-14", { + Test_utils.eq("File \"gadt_test.res\", line 235, characters 7-14", { kind: "Circle", radius: 1.5 }, { kind: "Circle", radius: 1.5 }); - Test_utils.eq("File \"gadt_test.res\", line 252, characters 7-14", "hi", "hi"); - Test_utils.eq("File \"gadt_test.res\", line 253, characters 7-14", 2, 2); - Test_utils.eq("File \"gadt_test.res\", line 254, characters 7-14", "u", "u"); - Test_utils.eq("File \"gadt_test.res\", line 255, characters 7-14", "u", "u"); + Test_utils.eq("File \"gadt_test.res\", line 236, characters 7-14", "hi", "hi"); + Test_utils.eq("File \"gadt_test.res\", line 237, characters 7-14", 2, 2); + Test_utils.eq("File \"gadt_test.res\", line 238, characters 7-14", "u", "u"); + Test_utils.eq("File \"gadt_test.res\", line 239, characters 7-14", "u", "u"); }); - Mocha.test("polymorphic recursion", () => Test_utils.eq("File \"gadt_test.res\", line 259, characters 7-14", 2, depth({ + Mocha.test("polymorphic recursion", () => Test_utils.eq("File \"gadt_test.res\", line 243, characters 7-14", 2, depth({ TAG: "Nest", _0: { TAG: "Nest", diff --git a/tests/tests/src/gadt_test.res b/tests/tests/src/gadt_test.res index f431b313cb..d8f1d9f77a 100644 --- a/tests/tests/src/gadt_test.res +++ b/tests/tests/src/gadt_test.res @@ -11,20 +11,18 @@ type rec expr<_> = | Pair(expr<'a>, expr<'b>): expr<('a, 'b)> | First(expr<('a, 'b)>): expr<'a> -let rec eval: - type a. expr => a = - expr => - switch expr { - | Int(n) => n - | Bool(b) => b - | Add(a, b) => eval(a) + eval(b) - | Equal(a, b) => eval(a) == eval(b) - | If(cond, yes, no) => eval(cond) ? eval(yes) : eval(no) - | Pair(a, b) => (eval(a), eval(b)) - | First(pair) => - let (a, _) = eval(pair) - a - } +let rec eval: type a. expr => a = expr => + switch expr { + | Int(n) => n + | Bool(b) => b + | Add(a, b) => eval(a) + eval(b) + | Equal(a, b) => eval(a) == eval(b) + | If(cond, yes, no) => eval(cond) ? eval(yes) : eval(no) + | Pair(a, b) => (eval(a), eval(b)) + | First(pair) => + let (a, _) = eval(pair) + a + } // Type witnesses: one function, a different result type per witness. type rec ty<_> = @@ -34,29 +32,25 @@ type rec ty<_> = | TPair(ty<'a>, ty<'b>): ty<('a, 'b)> | TOption(ty<'a>): ty> -let rec show: - type a. (ty, a) => string = - (ty, value) => - switch (ty, value) { - | (TInt, n) => Int.toString(n) - | (TString, s) => `"${s}"` - | (TList(_), list{}) => "[]" - | (TList(ty), list{x, ...rest}) => show(ty, x) ++ "::" ++ show(TList(ty), rest) - | (TPair(a, b), (x, y)) => "(" ++ show(a, x) ++ ", " ++ show(b, y) ++ ")" - | (TOption(_), None) => "None" - | (TOption(ty), Some(x)) => "Some(" ++ show(ty, x) ++ ")" - } +let rec show: type a. (ty, a) => string = (ty, value) => + switch (ty, value) { + | (TInt, n) => Int.toString(n) + | (TString, s) => `"${s}"` + | (TList(_), list{}) => "[]" + | (TList(ty), list{x, ...rest}) => show(ty, x) ++ "::" ++ show(TList(ty), rest) + | (TPair(a, b), (x, y)) => "(" ++ show(a, x) ++ ", " ++ show(b, y) ++ ")" + | (TOption(_), None) => "None" + | (TOption(ty), Some(x)) => "Some(" ++ show(ty, x) ++ ")" + } -let defaultOf: - type a. ty => a = - ty => - switch ty { - | TInt => 0 - | TString => "" - | TList(_) => list{} - | TPair(_, _) => throw(Invalid_argument("no default pair")) - | TOption(_) => None - } +let defaultOf: type a. ty => a = ty => + switch ty { + | TInt => 0 + | TString => "" + | TList(_) => list{} + | TPair(_, _) => throw(Invalid_argument("no default pair")) + | TOption(_) => None + } // A match on a refined index needs no case for impossible constructors. let intName = (ty: ty) => @@ -69,29 +63,27 @@ type rec equal<_, _> = Refl: equal<'a, 'a> let cast = (type a b, Refl: equal, x: a): b => x -let rec equalTy: - type a b. (ty, ty) => option> = - (a, b) => - switch (a, b) { - | (TInt, TInt) => Some(Refl) - | (TString, TString) => Some(Refl) - | (TList(a), TList(b)) => - switch equalTy(a, b) { - | Some(Refl) => Some(Refl) - | None => None - } - | (TOption(a), TOption(b)) => - switch equalTy(a, b) { - | Some(Refl) => Some(Refl) - | None => None - } - | (TPair(a1, b1), TPair(a2, b2)) => - switch (equalTy(a1, a2), equalTy(b1, b2)) { - | (Some(Refl), Some(Refl)) => Some(Refl) - | _ => None - } +let rec equalTy: type a b. (ty, ty) => option> = (a, b) => + switch (a, b) { + | (TInt, TInt) => Some(Refl) + | (TString, TString) => Some(Refl) + | (TList(a), TList(b)) => + switch equalTy(a, b) { + | Some(Refl) => Some(Refl) + | None => None + } + | (TOption(a), TOption(b)) => + switch equalTy(a, b) { + | Some(Refl) => Some(Refl) + | None => None + } + | (TPair(a1, b1), TPair(a2, b2)) => + switch (equalTy(a1, a2), equalTy(b1, b2)) { + | (Some(Refl), Some(Refl)) => Some(Refl) | _ => None } + | _ => None + } // Existential types: the payload type is hidden from the outside. type rec dynamic = Dynamic(ty<'a>, 'a): dynamic @@ -136,15 +128,13 @@ type rec format<_> = | IntArg(format<'a>): format 'a> | StringArg(format<'a>): format 'a> -let rec format: - type a. (format, string) => a = - (fmt, acc) => - switch fmt { - | End => acc - | Text(s, rest) => format(rest, acc ++ s) - | IntArg(rest) => n => format(rest, acc ++ Int.toString(n)) - | StringArg(rest) => s => format(rest, acc ++ s) - } +let rec format: type a. (format, string) => a = (fmt, acc) => + switch fmt { + | End => acc + | Text(s, rest) => format(rest, acc ++ s) + | IntArg(rest) => n => format(rest, acc ++ Int.toString(n)) + | StringArg(rest) => s => format(rest, acc ++ s) + } let sprintf = fmt => format(fmt, "") @@ -154,40 +144,34 @@ type rec field<_> = | StringField({s: string}): field | Empty: field -let fieldValue: - type a. field => a = - field => - switch field { - | IntField({n}) => n - | StringField({s}) => s - | Empty => () - } +let fieldValue: type a. field => a = field => + switch field { + | IntField({n}) => n + | StringField({s}) => s + | Empty => () + } @tag("kind") type rec shape<_> = | Circle({radius: float}): shape | Label({text: string}): shape -let shapeValue: - type a. shape => a = - shape => - switch shape { - | Circle({radius}) => radius - | Label({text}) => text - } +let shapeValue: type a. shape => a = shape => + switch shape { + | Circle({radius}) => radius + | Label({text}) => text + } @unboxed type rec primitive<_> = | Number(float): primitive | Str(string): primitive -let primitiveValue: - type a. primitive => a = - p => - switch p { - | Number(f) => f - | Str(s) => s - } +let primitiveValue: type a. primitive => a = p => + switch p { + | Number(f) => f + | Str(s) => s + } // Polymorphic recursion on a nested (non-regular) type. type rec nested<'a> = Flat('a) | Nest(nested>) diff --git a/tests/tests/src/value_binding_constraint.res b/tests/tests/src/value_binding_constraint.res index aeba636e5e..c2e26e78e1 100644 --- a/tests/tests/src/value_binding_constraint.res +++ b/tests/tests/src/value_binding_constraint.res @@ -2,13 +2,11 @@ type rec witness<'a> = | Int: witness | String: witness -let defaultValue: - type a. witness => a = - witness => - switch witness { - | Int => 42 - | String => "value" - } +let defaultValue: type a. witness => a = witness => + switch witness { + | Int => 42 + | String => "value" + } let intDefault: int = defaultValue(Int) let stringDefault: string = defaultValue(String)