diff --git a/src/passes/01-parser/reasonligo/Pretty.ml b/src/passes/01-parser/reasonligo/Pretty.ml index 84b8d7495..e925388e1 100644 --- a/src/passes/01-parser/reasonligo/Pretty.ml +++ b/src/passes/01-parser/reasonligo/Pretty.ml @@ -48,6 +48,7 @@ and pp_let_binding let_ (binding : let_binding) = in let rhs = pp_expr let_rhs in match let_rhs with + | EFun _ | ESeq _ | ERecord _ -> lhs ^^ rhs | _ -> prefix 2 0 lhs rhs @@ -130,7 +131,7 @@ and pp_field_pattern {value; _} = and pp_ptyped {value; _} = let {pattern; type_expr; _} = value in - group (pp_pattern pattern ^^ string ":" ^/^ pp_type_expr type_expr) + group (pp_pattern pattern ^^ string ": " ^^ pp_type_expr type_expr) and pp_type_decl decl = let {name; type_expr; _} = decl.value in @@ -374,7 +375,7 @@ and pp_fun {value; _} = match lhs_type with None -> empty | Some (_,e) -> - group (break 0 ^^ string ":" ^^ nest 2 (break 1 ^^ pp_type_expr e)) + group (break 0 ^^ string ": " ^^ nest 2 (pp_type_expr e)) in match body with | ESeq _ -> string "(" ^^ binders ^^ string ")" ^^ annot ^^ string " => " ^^ pp_expr body diff --git a/src/test/contracts/expected/address.religo.expected b/src/test/contracts/expected/address.religo.expected index 1f4535bb1..02a35089e 100644 --- a/src/test/contracts/expected/address.religo.expected +++ b/src/test/contracts/expected/address.religo.expected @@ -1,5 +1,4 @@ -let main = - (p: key_hash): address => { - let c: contract(unit) = Tezos.implicit_account(p); - Tezos.address(c) - }; +let main = (p: key_hash): address => { + let c: contract(unit) = Tezos.implicit_account(p); + Tezos.address(c) +}; diff --git a/src/test/contracts/expected/amount.religo.expected b/src/test/contracts/expected/amount.religo.expected index 78b7804a2..7f4dac3d6 100644 --- a/src/test/contracts/expected/amount.religo.expected +++ b/src/test/contracts/expected/amount.religo.expected @@ -1,7 +1,6 @@ -let check_ = - (p: unit): int => - if(Tezos.amount == 100000000mutez) { - 42 - } else { - 0 - }; +let check_ = (p: unit): int => + if(Tezos.amount == 100000000mutez) { + 42 + } else { + 0 + }; diff --git a/src/test/contracts/expected/bad_address_format.religo.expected b/src/test/contracts/expected/bad_address_format.religo.expected index ee7f13c0d..daa5b29ed 100644 --- a/src/test/contracts/expected/bad_address_format.religo.expected +++ b/src/test/contracts/expected/bad_address_format.religo.expected @@ -1,3 +1,2 @@ -let main = - (parameter: int, storage: address) => - ([] : list(operation), "KT1badaddr" : address); +let main = (parameter: int, storage: address) => + ([] : list(operation), "KT1badaddr" : address); diff --git a/src/test/contracts/expected/balance_constant.religo.expected b/src/test/contracts/expected/balance_constant.religo.expected index 6ae8a6f74..3fb310a5e 100644 --- a/src/test/contracts/expected/balance_constant.religo.expected +++ b/src/test/contracts/expected/balance_constant.religo.expected @@ -1,7 +1,6 @@ type storage = tez; -let main2 = - (p: unit, s: storage) => - ([] : list(operation), Tezos.balance); +let main2 = (p: unit, s: storage) => + ([] : list(operation), Tezos.balance); let main = (x: (unit, storage)) => main2(x[0], x[1]); diff --git a/src/test/contracts/expected/bytes_unpack.religo.expected b/src/test/contracts/expected/bytes_unpack.religo.expected index 662e82c3c..8e2b20a69 100644 --- a/src/test/contracts/expected/bytes_unpack.religo.expected +++ b/src/test/contracts/expected/bytes_unpack.religo.expected @@ -1,17 +1,14 @@ -let id_string = - (p: string): option(string) => { - let packed: bytes = Bytes.pack(p); - ((Bytes.unpack(packed)) : option(string)) - }; +let id_string = (p: string): option(string) => { + let packed: bytes = Bytes.pack(p); + ((Bytes.unpack(packed)) : option(string)) +}; -let id_int = - (p: int): option(int) => { - let packed: bytes = Bytes.pack(p); - ((Bytes.unpack(packed)) : option(int)) - }; +let id_int = (p: int): option(int) => { + let packed: bytes = Bytes.pack(p); + ((Bytes.unpack(packed)) : option(int)) +}; -let id_address = - (p: address): option(address) => { - let packed: bytes = Bytes.pack(p); - ((Bytes.unpack(packed)) : option(address)) - }; +let id_address = (p: address): option(address) => { + let packed: bytes = Bytes.pack(p); + ((Bytes.unpack(packed)) : option(address)) +}; diff --git a/src/test/contracts/expected/check_signature.religo.expected b/src/test/contracts/expected/check_signature.religo.expected index 77e46efe2..f50f2e554 100644 --- a/src/test/contracts/expected/check_signature.religo.expected +++ b/src/test/contracts/expected/check_signature.religo.expected @@ -1,5 +1,4 @@ -let check_signature = - (param: (key, signature, bytes)): bool => { - let (pk, signed, msg) = param; - Crypto.check(pk, signed, msg) - }; +let check_signature = (param: (key, signature, bytes)): bool => { + let (pk, signed, msg) = param; + Crypto.check(pk, signed, msg) +}; diff --git a/src/test/contracts/expected/closure.religo.expected b/src/test/contracts/expected/closure.religo.expected index 52cbf30ee..ed6b69611 100644 --- a/src/test/contracts/expected/closure.religo.expected +++ b/src/test/contracts/expected/closure.religo.expected @@ -1,7 +1,6 @@ -let test = - (k: int): int => { - let j: int = k + 5; - let close: (int => int) = (i: int) => i + j; - let j: int = 20; - close(20) - }; +let test = (k: int): int => { + let j: int = k + 5; + let close: (int => int) = (i: int) => i + j; + let j: int = 20; + close(20) +}; diff --git a/src/test/contracts/expected/condition-shadowing.religo.expected b/src/test/contracts/expected/condition-shadowing.religo.expected index 5c43e89a7..d77219f4b 100644 --- a/src/test/contracts/expected/condition-shadowing.religo.expected +++ b/src/test/contracts/expected/condition-shadowing.religo.expected @@ -1,13 +1,12 @@ -let main = - (i: int) => { +let main = (i: int) => { + let result = 0; + if(i == 2) { + + let result = 42; + result + } else { + let result = 0; - if(i == 2) { - - let result = 42; - result - } else { - - let result = 0; - result - } - }; + result + } +}; diff --git a/src/test/contracts/expected/condition.religo.expected b/src/test/contracts/expected/condition.religo.expected index f29a3be89..8049192f8 100644 --- a/src/test/contracts/expected/condition.religo.expected +++ b/src/test/contracts/expected/condition.religo.expected @@ -1,7 +1,6 @@ -let main = - (i: int) => - if(i == 2) { - 42 - } else { - 0 - }; +let main = (i: int) => + if(i == 2) { + 42 + } else { + 0 + }; diff --git a/src/test/contracts/expected/counter.religo.expected b/src/test/contracts/expected/counter.religo.expected index 14af3847f..5376359a4 100644 --- a/src/test/contracts/expected/counter.religo.expected +++ b/src/test/contracts/expected/counter.religo.expected @@ -1,5 +1,5 @@ type storage = int; -let main = - ((p, s): (int, storage)): (list(operation), storage) => - ([] : list(operation), p + s); +let main = ((p, s): (int, storage)) +: (list(operation), storage) => + ([] : list(operation), p + s); diff --git a/src/test/contracts/expected/empty_case.religo.expected b/src/test/contracts/expected/empty_case.religo.expected index 6705b108c..1051909b0 100644 --- a/src/test/contracts/expected/empty_case.religo.expected +++ b/src/test/contracts/expected/empty_case.religo.expected @@ -1,8 +1,7 @@ type foo = Bar(int) | Baz; -let main = - (f: foo): int => - switch(f) { - | Bar(i) => i - | Baz => (-1) - }; +let main = (f: foo): int => + switch(f) { + | Bar(i) => i + | Baz => (-1) + }; diff --git a/src/test/contracts/expected/eq_bool.religo.expected b/src/test/contracts/expected/eq_bool.religo.expected index ae49645a1..73671f764 100644 --- a/src/test/contracts/expected/eq_bool.religo.expected +++ b/src/test/contracts/expected/eq_bool.religo.expected @@ -1,7 +1,6 @@ -let main = - ((a, b): (bool, bool)) => - if(a == b) { - 999 - } else { - 1 - }; +let main = ((a, b): (bool, bool)) => + if(a == b) { + 999 + } else { + 1 + }; diff --git a/src/test/contracts/expected/failwith.religo.expected b/src/test/contracts/expected/failwith.religo.expected index 5e9680040..8f29675a1 100644 --- a/src/test/contracts/expected/failwith.religo.expected +++ b/src/test/contracts/expected/failwith.religo.expected @@ -1,7 +1,6 @@ type storage = unit; -let main = - (p: unit, storage) => - if(true) { - failwith("This contract always fails") - }; +let main = (p: unit, storage) => + if(true) { + failwith("This contract always fails") + }; diff --git a/src/test/contracts/expected/high-order.religo.expected b/src/test/contracts/expected/high-order.religo.expected index 52b5008f9..55cc25b1f 100644 --- a/src/test/contracts/expected/high-order.religo.expected +++ b/src/test/contracts/expected/high-order.religo.expected @@ -1,30 +1,25 @@ -let foobar = - (i: int): int => { - let foo: int => int = (i: int) => i; - let bar: ((int => int) => int) = - (f: (int => int)) => f(i); - bar(foo) - }; +let foobar = (i: int): int => { + let foo: int => int = (i: int) => i; + let bar: ((int => int) => int) = (f: (int => int)) => f(i); + bar(foo) +}; -let higher2 = - (i: int, f: (int => int)): int => { - let ii: int = f(i); - ii - }; +let higher2 = (i: int, f: (int => int)): int => { + let ii: int = f(i); + ii +}; -let foobar2 = - (i: int): int => { - let foo2: int => int = (i: int) => i; - higher2(i, foo2) - }; +let foobar2 = (i: int): int => { + let foo2: int => int = (i: int) => i; + higher2(i, foo2) +}; let a: int = 0; -let foobar3 = - (i: int): int => { - let foo2: int => int = (i: int) => a + i; - higher2(i, foo2) - }; +let foobar3 = (i: int): int => { + let foo2: int => int = (i: int) => a + i; + higher2(i, foo2) +}; let f = (i: int): int => i; @@ -32,16 +27,15 @@ 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 => { - let ii: int = f(g(i)); - ii - }; +let higher3 = (i: int, f: (int => int), g: (int => int)) +: int => { + let ii: int = f(g(i)); + ii +}; -let foobar5 = - (i: int): int => { - let a: int = 0; - let foo: int => int = (i: int) => a + i; - let goo: int => int = (i: int) => foo(i); - higher3(i, foo, goo) - }; +let foobar5 = (i: int): int => { + let a: int = 0; + let foo: int => int = (i: int) => a + i; + let goo: int => int = (i: int) => foo(i); + higher3(i, foo, goo) +}; diff --git a/src/test/contracts/expected/implicit_account.religo.expected b/src/test/contracts/expected/implicit_account.religo.expected index 8bfc216f8..0a679da2c 100644 --- a/src/test/contracts/expected/implicit_account.religo.expected +++ b/src/test/contracts/expected/implicit_account.religo.expected @@ -1,3 +1,2 @@ -let main = - (kh: key_hash): contract(unit) => - Tezos.implicit_account(kh); +let main = (kh: key_hash): contract(unit) => + Tezos.implicit_account(kh); diff --git a/src/test/contracts/expected/key_hash.religo.expected b/src/test/contracts/expected/key_hash.religo.expected index 38bb28e1c..a334e7140 100644 --- a/src/test/contracts/expected/key_hash.religo.expected +++ b/src/test/contracts/expected/key_hash.religo.expected @@ -1,6 +1,6 @@ -let check_hash_key = - (kh1_k2: (key_hash, key)): (bool, key_hash) => { - let (kh1, k2) = kh1_k2; - let kh2: key_hash = Crypto.hash_key(k2); - ((kh1 == kh2), kh2) - }; +let check_hash_key = (kh1_k2: (key_hash, key)) +: (bool, key_hash) => { + let (kh1, k2) = kh1_k2; + let kh2: key_hash = Crypto.hash_key(k2); + ((kh1 == kh2), kh2) +}; diff --git a/src/test/contracts/expected/lambda.religo.expected b/src/test/contracts/expected/lambda.religo.expected index 2de46c15d..46728296f 100644 --- a/src/test/contracts/expected/lambda.religo.expected +++ b/src/test/contracts/expected/lambda.religo.expected @@ -1,5 +1,4 @@ type storage = unit; -let main = - ((p, s): (unit, storage)): unit => - (((useless: unit)) => ())(()); +let main = ((p, s): (unit, storage)): unit => + (((useless: unit)) => ())(()); diff --git a/src/test/contracts/expected/lambda2.religo.expected b/src/test/contracts/expected/lambda2.religo.expected index e434e61c9..988de4d37 100644 --- a/src/test/contracts/expected/lambda2.religo.expected +++ b/src/test/contracts/expected/lambda2.religo.expected @@ -1,5 +1,4 @@ type storage = unit; -let main = - ((a, s): (unit, storage)): unit => - ((f: (unit => unit)) => f(()))((useless: unit) => unit); +let main = ((a, s): (unit, storage)): unit => + ((f: (unit => unit)) => f(()))((useless: unit) => unit); diff --git a/src/test/contracts/expected/letin.religo.expected b/src/test/contracts/expected/letin.religo.expected index 0bb052da1..7668015e1 100644 --- a/src/test/contracts/expected/letin.religo.expected +++ b/src/test/contracts/expected/letin.religo.expected @@ -1,13 +1,12 @@ type storage = (int, int); -let main = - (n: (int, storage)): (list(operation), storage) => { - let x: (int, int) = { - let x: int = 7; - (x + n[0], n[1][0] + n[1][1]) - }; - ([] : list(operation), x) +let main = (n: (int, storage)): (list(operation), storage) => { + let x: (int, int) = { + let x: int = 7; + (x + n[0], n[1][0] + n[1][1]) }; + ([] : list(operation), x) +}; let f0 = (a: string) => true; @@ -15,21 +14,19 @@ let f1 = (a: string) => true; let f2 = (a: string) => true; -let letin_nesting = - (_: unit) => { - let s = "test"; - let p0 = f0(s); - assert(p0); - let p1 = f1(s); - assert(p1); - let p2 = f2(s); - assert(p2); - s - }; +let letin_nesting = (_: unit) => { + let s = "test"; + let p0 = f0(s); + assert(p0); + let p1 = f1(s); + assert(p1); + let p2 = f2(s); + assert(p2); + s +}; -let letin_nesting2 = - (x: int) => { - let y = 2; - let z = 3; - x + y + z - }; +let letin_nesting2 = (x: int) => { + let y = 2; + let z = 3; + x + y + z +}; diff --git a/src/test/contracts/expected/list.religo.expected b/src/test/contracts/expected/list.religo.expected index 18f6653d3..e2c2c6867 100644 --- a/src/test/contracts/expected/list.religo.expected +++ b/src/test/contracts/expected/list.religo.expected @@ -10,30 +10,26 @@ let y: list(int) = [3, 4, 5]; let z: list(int) = [2, ...y]; -let main = - ((action, s): (parameter, storage)): return => { - let storage = - switch(action) { - | [] => s - | [hd, ...tl] => (s[0] + hd, tl) - }; - ([] : list(operation), storage) - }; +let main = ((action, s): (parameter, storage)): return => { + let storage = + switch(action) { + | [] => s + | [hd, ...tl] => (s[0] + hd, tl) + }; + ([] : list(operation), storage) +}; let size_ = (s: list(int)): nat => List.length(s); -let fold_op = - (s: list(int)): int => { - let aggregate = (t: (int, int)) => t[0] + t[1]; - List.fold(aggregate, s, 10) - }; +let fold_op = (s: list(int)): int => { + let aggregate = (t: (int, int)) => t[0] + t[1]; + List.fold(aggregate, s, 10) +}; -let map_op = - (s: list(int)): list(int) => - List.map((cur: int) => cur + 1, s); +let map_op = (s: list(int)): list(int) => + List.map((cur: int) => cur + 1, s); -let iter_op = - (s: list(int)): unit => { - let do_nothing = (useless: int) => unit; - List.iter(do_nothing, s) - }; +let iter_op = (s: list(int)): unit => { + let do_nothing = (useless: int) => unit; + List.iter(do_nothing, s) +}; diff --git a/src/test/contracts/expected/loop.religo.expected b/src/test/contracts/expected/loop.religo.expected index aac2af16c..130c2cd06 100644 --- a/src/test/contracts/expected/loop.religo.expected +++ b/src/test/contracts/expected/loop.religo.expected @@ -1,52 +1,47 @@ -let rec aux_simple = - (i: int): int => - if(i < 100) { - aux_simple(i + 1) - } else { - i - }; +let rec aux_simple = (i: int): int => + if(i < 100) { + aux_simple(i + 1) + } else { + i + }; let counter_simple = (n: int): int => aux_simple(n); type sum_aggregator = {counter: int, sum: int }; -let counter = - (n: int): int => { - let initial: sum_aggregator = { - counter: 0, - sum: 0 - }; - let rec aggregate = - (prev: sum_aggregator): int => - if(prev.counter <= n) { - - - aggregate({ - counter: prev.counter + 1, - sum: prev.counter + prev.sum - }) - } else { - prev.sum - }; - aggregate(initial) +let counter = (n: int): int => { + let initial: sum_aggregator = { + counter: 0, + sum: 0 }; - -let rec aux_nest = - (prev: sum_aggregator): sum_aggregator => - if(prev.counter < 100) { + let rec aggregate = (prev: sum_aggregator): int => + if(prev.counter <= n) { - let sum: int = prev.sum + aux_simple(prev.counter); - aux_nest({counter: prev.counter + 1, sum: sum }) + + aggregate({ + counter: prev.counter + 1, + sum: prev.counter + prev.sum + }) } else { - ({counter: prev.counter, sum: prev.sum }) + prev.sum }; + aggregate(initial) +}; -let counter_nest = - (n: int): int => { - let initial: sum_aggregator = { - counter: 0, - sum: 0 - }; - let out: sum_aggregator = aux_nest(initial); - out.sum +let rec aux_nest = (prev: sum_aggregator): sum_aggregator => + if(prev.counter < 100) { + + let sum: int = prev.sum + aux_simple(prev.counter); + aux_nest({counter: prev.counter + 1, sum: sum }) + } else { + ({counter: prev.counter, sum: prev.sum }) }; + +let counter_nest = (n: int): int => { + let initial: sum_aggregator = { + counter: 0, + sum: 0 + }; + let out: sum_aggregator = aux_nest(initial); + out.sum +}; diff --git a/src/test/contracts/expected/map.religo.expected b/src/test/contracts/expected/map.religo.expected index 918dd70c1..0106bca64 100644 --- a/src/test/contracts/expected/map.religo.expected +++ b/src/test/contracts/expected/map.religo.expected @@ -12,24 +12,21 @@ let map1: foobar = let map2: foobar = Map.literal([(23, 0), (42, 0)]); -let set_ = - (n: int, m: foobar): foobar => Map.update(23, Some (n), m); +let set_ = (n: int, m: foobar): foobar => + Map.update(23, Some (n), m); let add = (n: int, m: foobar): foobar => Map.add(23, n, m); let rm = (m: foobar): foobar => Map.remove(42, m); -let patch_ = - (m: foobar): foobar => - Map.literal([(0, 5), (1, 6), (2, 7)]); +let patch_ = (m: foobar): foobar => + Map.literal([(0, 5), (1, 6), (2, 7)]); -let patch_empty = - (m: foobar): foobar => - Map.literal([(0, 0), (1, 1), (2, 2)]); +let patch_empty = (m: foobar): foobar => + Map.literal([(0, 0), (1, 1), (2, 2)]); -let patch_deep = - (m: (foobar, nat)): (foobar, nat) => - (Map.literal([(0, 0), (1, 9), (2, 2)]), 10n); +let patch_deep = (m: (foobar, nat)): (foobar, nat) => + (Map.literal([(0, 0), (1, 9), (2, 2)]), 10n); let size_ = (m: foobar): nat => Map.size(m); @@ -39,29 +36,24 @@ let get_ = (m: foobar): option(int) => Map.find_opt(42, m); let mem = (km: (int, foobar)): bool => Map.mem(km[0], km[1]); -let iter_op = - (m: foobar): unit => { - let assert_eq = (i: int, j: int) => assert(i == j); - Map.iter(assert_eq, m) - }; +let iter_op = (m: foobar): unit => { + let assert_eq = (i: int, j: int) => assert(i == j); + Map.iter(assert_eq, m) +}; -let map_op = - (m: foobar): foobar => { - let increment = (z: int, j: int) => j + 1; - Map.map(increment, m) - }; +let map_op = (m: foobar): foobar => { + let increment = (z: int, j: int) => j + 1; + Map.map(increment, m) +}; -let fold_op = - (m: foobar): foobar => { - let aggregate = - (i: int, j: (int, int)) => i + j[0] + j[1]; - Map.fold(aggregate, m, 10) - }; +let fold_op = (m: foobar): foobar => { + let aggregate = (i: int, j: (int, int)) => i + j[0] + j[1]; + Map.fold(aggregate, m, 10) +}; -let deep_op = - (m: foobar): foobar => { - let coco = (0, m); - let coco = (0, Map.remove(42, coco[1])); - let coco = (0, Map.update(32, Some (16), coco[1])); - coco[1] - }; +let deep_op = (m: foobar): foobar => { + let coco = (0, m); + let coco = (0, Map.remove(42, coco[1])); + let coco = (0, Map.update(32, Some (16), coco[1])); + coco[1] +}; diff --git a/src/test/contracts/expected/match.religo.expected b/src/test/contracts/expected/match.religo.expected index e3672aa30..be17f120e 100644 --- a/src/test/contracts/expected/match.religo.expected +++ b/src/test/contracts/expected/match.religo.expected @@ -4,12 +4,11 @@ type parameter = Add(int) | Sub(int); type return = (list(operation), storage); -let main = - ((action, store): (parameter, storage)) => { - let store = - store + (switch(action) { - | Add(n) => n - | Sub(n) => -n - }); - (([] : list(operation)), store) - }; +let main = ((action, store): (parameter, storage)) => { + let store = + store + (switch(action) { + | Add(n) => n + | Sub(n) => -n + }); + (([] : list(operation)), store) +}; diff --git a/src/test/contracts/expected/match_bis.religo.expected b/src/test/contracts/expected/match_bis.religo.expected index da5710d68..7df5fd566 100644 --- a/src/test/contracts/expected/match_bis.religo.expected +++ b/src/test/contracts/expected/match_bis.religo.expected @@ -6,12 +6,11 @@ let add = ((a: int), (b: int)) => a + b; let sub = ((a: int), (b: int)) => a - b; -let main = - ((action, store): (parameter, storage)) => { - let store = - switch(action) { - | Increment(n) => add(store, n) - | Decrement(n) => sub(store, n) - }; - (([] : list(operation)), store) - }; +let main = ((action, store): (parameter, storage)) => { + let store = + switch(action) { + | Increment(n) => add(store, n) + | Decrement(n) => sub(store, n) + }; + (([] : list(operation)), store) +}; diff --git a/src/test/contracts/expected/michelson_pair_tree.religo.expected b/src/test/contracts/expected/michelson_pair_tree.religo.expected index 74a3c9595..206fe57e1 100644 --- a/src/test/contracts/expected/michelson_pair_tree.religo.expected +++ b/src/test/contracts/expected/michelson_pair_tree.religo.expected @@ -5,8 +5,7 @@ type storage = michelson_pair type return = (list(operation), storage); -let main = - ((action, store): (unit, storage)): return => { - let foo = (3, (1, 2n)); - (([] : list(operation)), (foo : storage)) - }; +let main = ((action, store): (unit, storage)): return => { + let foo = (3, (1, 2n)); + (([] : list(operation)), (foo : storage)) +}; diff --git a/src/test/contracts/expected/multiple-parameters.religo.expected b/src/test/contracts/expected/multiple-parameters.religo.expected index 7c5a6d198..aae363564 100644 --- a/src/test/contracts/expected/multiple-parameters.religo.expected +++ b/src/test/contracts/expected/multiple-parameters.religo.expected @@ -1,6 +1,6 @@ -let abcde_curried = - (a: int, b: int, c: int, d: int, e: int): int => c + e + 3; +let abcde_curried = (a: int, b: int, c: int, d: int, e: int) +: int => + c + e + 3; -let abcde = - (x: (int, int, int, int, int)): int => - abcde_curried(x[0], x[1], x[2], x[3], x[4]); +let abcde = (x: (int, int, int, int, int)): int => + abcde_curried(x[0], x[1], x[2], x[3], x[4]); diff --git a/src/test/contracts/expected/multisig.religo.expected b/src/test/contracts/expected/multisig.religo.expected index 6be99ec43..ddb7b981c 100644 --- a/src/test/contracts/expected/multisig.religo.expected +++ b/src/test/contracts/expected/multisig.religo.expected @@ -29,61 +29,53 @@ type return = (list(operation), storage); type parameter = CheckMessage(check_message_pt); -let check_message = - ((param, s): (check_message_pt, storage)): return => { - let message: message = param.message; - let s = - if(param.counter != s.counter) { - (failwith("Counters does not match") : storage) - } else { - - let packed_payload: bytes = - - Bytes.pack((message, param.counter, s.id, chain_id)); - let valid: nat = 0n; - let keys: authorized_keys = s.auth; - let aux = - ((vk, pkh_sig): - ((nat, authorized_keys), (key_hash, signature))) - : - (nat, authorized_keys) => { - let (valid, keys) = vk; - switch(keys) { - | [] => vk - | [key, ...keys] => - if(pkh_sig[0] == Crypto.hash_key(key)) { - - let valid = - if( - Crypto.check(key, - pkh_sig[1], - packed_payload)) { - valid + 1n - } else { - (failwith("Invalid signature") : nat) - }; - (valid, keys) +let check_message = ((param, s): (check_message_pt, storage)) +: return => { + let message: message = param.message; + let s = + if(param.counter != s.counter) { + (failwith("Counters does not match") : storage) + } else { + + let packed_payload: bytes = + Bytes.pack((message, param.counter, s.id, chain_id)); + let valid: nat = 0n; + let keys: authorized_keys = s.auth; + let aux = ((vk, pkh_sig): ((nat, authorized_keys), + (key_hash, signature))): (nat, authorized_keys) => { + let (valid, keys) = vk; + switch(keys) { + | [] => vk + | [key, ...keys] => + if(pkh_sig[0] == Crypto.hash_key(key)) { + + let valid = + if( + Crypto.check(key, pkh_sig[1], packed_payload)) { + valid + 1n } else { - (valid, keys) - } + (failwith("Invalid signature") : nat) + }; + (valid, keys) + } else { + (valid, keys) } - }; - let (valid, keys) = - List.fold(aux, param.signatures, (valid, keys)); - if(valid < s.threshold) { - - ( - failwith("Not enough signatures passed the check") - : storage) - } else { - {...s, counter: s.counter + 1n} } }; - (message(unit), s) - }; - -let main = - ((action, store): (parameter, storage)): return => - switch(action) { - | CheckMessage(p) => check_message((p, store)) + let (valid, keys) = + List.fold(aux, param.signatures, (valid, keys)); + if(valid < s.threshold) { + + (failwith("Not enough signatures passed the check") + : storage) + } else { + {...s, counter: s.counter + 1n} + } }; + (message(unit), s) +}; + +let main = ((action, store): (parameter, storage)): return => + switch(action) { + | CheckMessage(p) => check_message((p, store)) + }; diff --git a/src/test/contracts/expected/no_semicolon.religo.expected b/src/test/contracts/expected/no_semicolon.religo.expected index 352b36e54..ea3b13c2c 100644 --- a/src/test/contracts/expected/no_semicolon.religo.expected +++ b/src/test/contracts/expected/no_semicolon.religo.expected @@ -1,15 +1,13 @@ type f = int; -let a = - (b: f) => { - if(b == 2) { - 3 - } else { - 4 - } - }; - -let c = - (c: f) => { +let a = (b: f) => { + if(b == 2) { 3 - }; + } else { + 4 + } +}; + +let c = (c: f) => { + 3 +}; diff --git a/src/test/contracts/expected/pledge.religo.expected b/src/test/contracts/expected/pledge.religo.expected index eaf62761c..9c8044a9c 100644 --- a/src/test/contracts/expected/pledge.religo.expected +++ b/src/test/contracts/expected/pledge.religo.expected @@ -4,29 +4,27 @@ type parameter = Donate(unit) | Distribute((unit => list(operation))); -let donate = - ((p, s): (unit, storage)): (list(operation), storage) => { - (([] : list(operation)), s) - }; +let donate = ((p, s): (unit, storage)) +: (list(operation), storage) => { + (([] : list(operation)), s) +}; -let distribute = - ((p, s): ((unit => list(operation)), storage)) - : - (list(operation), storage) => { - if(Tezos.sender == s) { - (p(()), s) - } else { - - ( - failwith("You're not the oracle for this distribution.") - : (list(operation), storage)) - } - }; +let distribute = ((p, s): ((unit => list(operation)), + storage)): (list(operation), storage) => { + if(Tezos.sender == s) { + (p(()), s) + } else { + + ( + failwith("You're not the oracle for this distribution.") + : (list(operation), storage)) + } +}; -let main = - ((p, s): (parameter, storage)): (list(operation), storage) => { - switch(p) { - | Donate => donate(((), s)) - | Distribute msg => distribute((msg, s)) - } - }; +let main = ((p, s): (parameter, storage)) +: (list(operation), storage) => { + switch(p) { + | Donate => donate(((), s)) + | Distribute msg => distribute((msg, s)) + } +}; diff --git a/src/test/contracts/expected/record.religo.expected b/src/test/contracts/expected/record.religo.expected index c41cc77f9..f923c8fd0 100644 --- a/src/test/contracts/expected/record.religo.expected +++ b/src/test/contracts/expected/record.religo.expected @@ -24,5 +24,6 @@ let br: big_record = {a: 23, b: 23, c: 23, d: 23, e: 23 }; type double_record = {inner: abc }; -let modify_inner = - (r: double_record): double_record => {...r, inner.b: 2048}; +let modify_inner = (r: double_record): double_record => + {...r, + inner.b: 2048}; diff --git a/src/test/contracts/expected/recursion.religo.expected b/src/test/contracts/expected/recursion.religo.expected index bad33a7ba..70cf03318 100644 --- a/src/test/contracts/expected/recursion.religo.expected +++ b/src/test/contracts/expected/recursion.religo.expected @@ -1,15 +1,13 @@ -let rec sum = - ((n, acc): (int, int)): int => - if(n < 1) { - acc - } else { - sum((n - 1, acc + n)) - }; +let rec sum = ((n, acc): (int, int)): int => + if(n < 1) { + acc + } else { + sum((n - 1, acc + n)) + }; -let rec fibo = - ((n, n_1, n_0): (int, int, int)): int => - if(n < 2) { - n_1 - } else { - fibo((n - 1, n_1 + n_0, n_1)) - }; +let rec fibo = ((n, n_1, n_0): (int, int, int)): int => + if(n < 2) { + n_1 + } else { + fibo((n - 1, n_1 + n_0, n_1)) + }; diff --git a/src/test/contracts/expected/set_arithmetic.religo.expected b/src/test/contracts/expected/set_arithmetic.religo.expected index 7c9edfd3b..23094e255 100644 --- a/src/test/contracts/expected/set_arithmetic.religo.expected +++ b/src/test/contracts/expected/set_arithmetic.religo.expected @@ -1,16 +1,14 @@ -let literal_op = - (p: unit): set(string) => - Set.literal(["foo", "bar", "foobar"]); +let literal_op = (p: unit): set(string) => + Set.literal(["foo", "bar", "foobar"]); -let add_op = - (s: set(string)): set(string) => Set.add("foobar", s); +let add_op = (s: set(string)): set(string) => + Set.add("foobar", s); -let remove_op = - (s: set(string)): set(string) => Set.remove("foobar", s); +let remove_op = (s: set(string)): set(string) => + Set.remove("foobar", s); -let remove_deep = - (s: (set(string), nat)): set(string) => - Set.remove("foobar", s[0]); +let remove_deep = (s: (set(string), nat)): set(string) => + Set.remove("foobar", s[0]); let mem_op = (s: set(string)): bool => Set.mem("foobar", s); diff --git a/src/test/contracts/expected/set_delegate.religo.expected b/src/test/contracts/expected/set_delegate.religo.expected index 00c9439c1..cd18f5538 100644 --- a/src/test/contracts/expected/set_delegate.religo.expected +++ b/src/test/contracts/expected/set_delegate.religo.expected @@ -1,5 +1,4 @@ -let main = - (p: key_hash): list(operation) => { - let unused: operation = (Tezos.set_delegate(Some (p))); - ([] : list(operation)) - }; +let main = (p: key_hash): list(operation) => { + let unused: operation = (Tezos.set_delegate(Some (p))); + ([] : list(operation)) +}; diff --git a/src/test/contracts/expected/super-counter.religo.expected b/src/test/contracts/expected/super-counter.religo.expected index 234d2dcf6..675f49db8 100644 --- a/src/test/contracts/expected/super-counter.religo.expected +++ b/src/test/contracts/expected/super-counter.religo.expected @@ -4,12 +4,11 @@ type storage = int; type return = (list(operation), storage); -let main = - ((action, store): (parameter, storage)): return => { - let store = - switch(action) { - | Increment(n) => store + n - | Decrement(n) => store - n - }; - ([] : list(operation), store) - }; +let main = ((action, store): (parameter, storage)): return => { + let store = + switch(action) { + | Increment(n) => store + n + | Decrement(n) => store - n + }; + ([] : list(operation), store) +}; diff --git a/src/test/contracts/expected/tuple_param_destruct.religo.expected b/src/test/contracts/expected/tuple_param_destruct.religo.expected index c5d0d7deb..15245a084 100644 --- a/src/test/contracts/expected/tuple_param_destruct.religo.expected +++ b/src/test/contracts/expected/tuple_param_destruct.religo.expected @@ -1,4 +1,4 @@ let sum = ((result, i): (int, int)): int => result - i; -let parentheses = - (((((result, i)))): (((int, int)))): int => result - i; +let parentheses = (((((result, i)))): (((int, int)))): int => + result - i; diff --git a/src/test/contracts/expected/tuple_type.religo.expected b/src/test/contracts/expected/tuple_type.religo.expected index 05fff0a65..8bc008c3b 100644 --- a/src/test/contracts/expected/tuple_type.religo.expected +++ b/src/test/contracts/expected/tuple_type.religo.expected @@ -1,44 +1,40 @@ type fun_type = (int, int) => int; -let arguments = - (b: int, c: int) => { - b + c - }; +let arguments = (b: int, c: int) => { + b + c +}; let arguments_type_def = (b: fun_type) => b(5, 3); -let arguments_test = - (_: int) => arguments_type_def(arguments); +let arguments_test = (_: int) => + arguments_type_def(arguments); type tuple_type = ((int, int)) => int; -let tuple = - ((a, b): (int, int)) => { - a + b - }; +let tuple = ((a, b): (int, int)) => { + a + b +}; let tuple_type_def = (b: tuple_type) => b((5, 3)); let tuple_test = (_: int) => tuple_type_def(tuple); -let arguments_inline = - (b: int, c: int) => { - b + c - }; +let arguments_inline = (b: int, c: int) => { + b + c +}; -let arguments_type_def_inline = - (b: (int, int) => int) => b(5, 3); +let arguments_type_def_inline = (b: (int, int) => int) => + b(5, 3); -let arguments_test_inline = - (_: int) => arguments_type_def_inline(arguments_inline); +let arguments_test_inline = (_: int) => + arguments_type_def_inline(arguments_inline); -let tuple_inline = - ((a, b): (int, int)) => { - a + b - }; +let tuple_inline = ((a, b): (int, int)) => { + a + b +}; -let tuple_type_def_inline = - (b: ((int, int)) => int) => b((5, 3)); +let tuple_type_def_inline = (b: ((int, int)) => int) => + b((5, 3)); -let tuple_test_inline = - (_: int) => tuple_type_def_inline(tuple_inline); +let tuple_test_inline = (_: int) => + tuple_type_def_inline(tuple_inline); diff --git a/src/test/contracts/expected/tuples_no_annotation.religo.expected b/src/test/contracts/expected/tuples_no_annotation.religo.expected index 1e49fee5d..38bc4f153 100644 --- a/src/test/contracts/expected/tuples_no_annotation.religo.expected +++ b/src/test/contracts/expected/tuples_no_annotation.religo.expected @@ -2,7 +2,6 @@ type storage = (int, string, nat, bool); type parameter = int; -let main = - ((p, storage): (parameter, storage)) => { - ([] : list(operation), (2, "2", 2n, false)) - }; +let main = ((p, storage): (parameter, storage)) => { + ([] : list(operation), (2, "2", 2n, false)) +}; diff --git a/src/test/contracts/expected/website2.religo.expected b/src/test/contracts/expected/website2.religo.expected index 1915b5f31..75257eea0 100644 --- a/src/test/contracts/expected/website2.religo.expected +++ b/src/test/contracts/expected/website2.religo.expected @@ -6,12 +6,11 @@ let add = ((a, b): (int, int)): int => a + b; let sub = ((a, b): (int, int)): int => a - b; -let main = - ((p, storage): (parameter, storage)) => { - let storage = - switch(p) { - | Increment(n) => add((storage, n)) - | Decrement(n) => sub((storage, n)) - }; - ([] : list(operation), storage) - }; +let main = ((p, storage): (parameter, storage)) => { + let storage = + switch(p) { + | Increment(n) => add((storage, n)) + | Decrement(n) => sub((storage, n)) + }; + ([] : list(operation), storage) +};