diff --git a/src/passes/1-parser/reasonligo/Parser.mly b/src/passes/1-parser/reasonligo/Parser.mly index 88c01af3b..4199b85e3 100644 --- a/src/passes/1-parser/reasonligo/Parser.mly +++ b/src/passes/1-parser/reasonligo/Parser.mly @@ -430,7 +430,18 @@ type_expr_simple: TProd {region = cover $1 $3; value=$2} } | "(" type_expr_simple "=>" type_expr_simple ")" { - TFun {region = cover $1 $5; value=$2,$3,$4} } + TPar { + value = { + lpar = $1; + rpar = $5; + inside = TFun { + region = cover (type_expr_to_region $2) (type_expr_to_region $4); + value=$2,$3,$4 + } + }; + region = cover $1 $5; + } +} type_annotation_simple: ":" type_expr_simple { $1,$2 } diff --git a/src/passes/1-parser/reasonligo/Pretty.ml b/src/passes/1-parser/reasonligo/Pretty.ml index 634e4d5a4..1ac0371c4 100644 --- a/src/passes/1-parser/reasonligo/Pretty.ml +++ b/src/passes/1-parser/reasonligo/Pretty.ml @@ -50,11 +50,8 @@ and pp_let_binding let_ (binding : let_binding) = | Some (_,e) -> patterns ^^ group (break 0 ^^ string ": " ^^ pp_type_expr e ^^ string " = ") in - match let_rhs with - (* | EFun { } -> *) - | e -> - let rhs = pp_expr e - in prefix 2 0 lhs rhs + let rhs = pp_expr let_rhs + in prefix 2 0 lhs rhs and pp_pattern = function PConstr p -> pp_pconstr p @@ -403,7 +400,7 @@ and pp_seq {value; _} = and pp_type_expr = function TProd t -> pp_cartesian t -| TSum t -> pp_variants t +| TSum t -> break 0 ^^ pp_variants t | TRecord t -> pp_fields t | TApp t -> pp_type_app t | TFun t -> pp_fun_type t diff --git a/src/test/contracts/expected/high-order.religo b/src/test/contracts/expected/high-order.religo index e4e0652d9..eb3de997d 100644 --- a/src/test/contracts/expected/high-order.religo +++ b/src/test/contracts/expected/high-order.religo @@ -3,12 +3,12 @@ let foobar = { let foo: int => int = (i: int) => i; let bar: ((int => int) => int) = - (f: int => int) => f(i); + (f: (int => int)) => f(i); bar(foo) }; let higher2 = - (i: int, f: int => int): int => + (i: int, f: (int => int)): int => { let ii: int = f(i); ii @@ -37,7 +37,7 @@ let g = (i: int): int => f(i); let foobar4 = (i: int): int => g(g(i)); let higher3 = - (i: int, f: int => int, g: int => int): int => + (i: int, f: (int => int), g: (int => int)): int => { let ii: int = f(g(i)); ii diff --git a/src/test/contracts/expected/lambda2.religo b/src/test/contracts/expected/lambda2.religo index d3026ba76..e434e61c9 100644 --- a/src/test/contracts/expected/lambda2.religo +++ b/src/test/contracts/expected/lambda2.religo @@ -2,4 +2,4 @@ type storage = unit; let main = ((a, s): (unit, storage)): unit => - ((f: unit => unit) => f(()))((useless: unit) => unit); + ((f: (unit => unit)) => f(()))((useless: unit) => unit); diff --git a/src/test/contracts/expected/pledge.religo b/src/test/contracts/expected/pledge.religo index 763ab7bb2..a8ef96c34 100644 --- a/src/test/contracts/expected/pledge.religo +++ b/src/test/contracts/expected/pledge.religo @@ -1,6 +1,7 @@ type storage = address; -type parameter = Donate(unit) +type parameter = + Donate(unit) | Distribute((unit => list(operation))); let donate = @@ -10,7 +11,7 @@ let donate = }; let distribute = - ((p, s): (unit => list(operation), storage)) + ((p, s): ((unit => list(operation)), storage)) : (list(operation), storage) => {