ReasonLIGO improvements.
This commit is contained in:
parent
cee9cc841e
commit
a688a1afe4
@ -120,8 +120,8 @@ and pp_ptuple {value; _} =
|
||||
| p::items ->
|
||||
group (break 1 ^^ pp_pattern p ^^ string ",") ^^ app items
|
||||
in if tail = []
|
||||
then string "(" ^^ pp_pattern head ^^ string ")"
|
||||
else string "(" ^^ pp_pattern head ^^ string "," ^^ app (List.map snd tail) ^^ string ")"
|
||||
then string "(" ^^ nest 1 (pp_pattern head) ^^ string ")"
|
||||
else string "(" ^^ nest 1 (pp_pattern head ^^ string "," ^^ app (List.map snd tail)) ^^ string ")"
|
||||
|
||||
and pp_precord fields = pp_ne_injection pp_field_pattern fields
|
||||
|
||||
@ -162,7 +162,7 @@ and pp_expr = function
|
||||
|
||||
and pp_case_expr {value; _} =
|
||||
let {expr; cases; _} = value in
|
||||
group (string "switch" ^^ string "(" ^^ pp_expr expr ^^ (string ") " ^^ string "{")
|
||||
group (string "switch" ^^ string "(" ^^ nest 1 (pp_expr expr) ^^ (string ") " ^^ string "{")
|
||||
^^ (pp_cases cases) ^^ hardline ^^ string "}" )
|
||||
|
||||
and pp_cases {value; _} =
|
||||
@ -178,7 +178,7 @@ and pp_clause {value; _} =
|
||||
and pp_cond_expr {value; _} =
|
||||
let {test; ifso; kwd_else; ifnot; _} = value in
|
||||
let if_then =
|
||||
string "if" ^^ string "(" ^^ pp_expr test ^^ string ")" ^^ string " {" ^^ break 0
|
||||
string "if" ^^ string " (" ^^ pp_expr test ^^ string ")" ^^ string " {" ^^ break 0
|
||||
^^ group (nest 2 (break 2 ^^ pp_expr ifso)) ^^ hardline ^^ string "}" in
|
||||
if kwd_else#is_ghost then
|
||||
if_then
|
||||
@ -350,8 +350,8 @@ and pp_tuple_expr {value; _} =
|
||||
| e::items ->
|
||||
group (break 1 ^^ pp_expr e ^^ string ",") ^^ app items
|
||||
in if tail = []
|
||||
then string "(" ^^ pp_expr head ^^ string ")"
|
||||
else string "(" ^^ pp_expr head ^^ string "," ^^ app (List.map snd tail) ^^ string ")"
|
||||
then string "(" ^^ nest 1 (pp_expr head) ^^ string ")"
|
||||
else string "(" ^^ nest 1 (pp_expr head ^^ string "," ^^ app (List.map snd tail)) ^^ string ")"
|
||||
|
||||
and pp_par_expr {value; _} =
|
||||
string "(" ^^ nest 1 (pp_expr value.inside ^^ string ")")
|
||||
@ -378,8 +378,8 @@ and pp_fun {value; _} =
|
||||
group (break 0 ^^ string ": " ^^ nest 2 (pp_type_expr e))
|
||||
in
|
||||
match body with
|
||||
| ESeq _ -> string "(" ^^ binders ^^ string ")" ^^ annot ^^ string " => " ^^ pp_expr body
|
||||
| _ -> (prefix 2 0 (string "(" ^^ binders ^^ string ")" ^^ annot
|
||||
| ESeq _ -> string "(" ^^ nest 1 binders ^^ string ")" ^^ annot ^^ string " => " ^^ pp_expr body
|
||||
| _ -> (prefix 2 0 (string "(" ^^ nest 1 binders ^^ string ")" ^^ annot
|
||||
^^ string " => ") (pp_expr body))
|
||||
|
||||
and pp_seq {value; _} =
|
||||
@ -412,7 +412,7 @@ and pp_cartesian {value; _} =
|
||||
| e::items ->
|
||||
group (break 1 ^^ pp_type_expr e ^^ string ",") ^^ app items
|
||||
in
|
||||
string "(" ^^ pp_type_expr head ^^ (if tail <> [] then string "," else empty) ^^ app (List.map snd tail) ^^ string ")"
|
||||
string "(" ^^ nest 1 (pp_type_expr head ^^ (if tail <> [] then string "," else empty) ^^ app (List.map snd tail)) ^^ string ")"
|
||||
|
||||
and pp_variants {value; _} =
|
||||
let head, tail = value in
|
||||
@ -445,7 +445,7 @@ and pp_field_decl {value; _} =
|
||||
|
||||
and pp_type_app {value; _} =
|
||||
let ctor, tuple = value in
|
||||
prefix 2 0 (pp_type_constr ctor) (string "(" ^^ pp_type_tuple tuple ^^ string ")")
|
||||
prefix 2 0 (pp_type_constr ctor) (string "(" ^^ nest 1 (pp_type_tuple tuple) ^^ string ")")
|
||||
|
||||
and pp_type_tuple {value; _} =
|
||||
let head, tail = value.inside in
|
||||
@ -474,7 +474,7 @@ and pp_fun_type {value; _} =
|
||||
match lhs, rhs with
|
||||
| _, TFun tf -> string "(" ^^ pp_type_expr lhs ^^ string ", " ^^ pp_fun_args tf
|
||||
| TVar _ , _ -> group (pp_type_expr lhs ^^ string " =>" ^/^ pp_type_expr rhs)
|
||||
| _ -> group (string "(" ^^ pp_type_expr lhs ^^ string ")" ^^ string " =>" ^/^ pp_type_expr rhs)
|
||||
| _ -> group (string "(" ^^ nest 1 (pp_type_expr lhs) ^^ string ")" ^^ string " =>" ^/^ pp_type_expr rhs)
|
||||
|
||||
and pp_type_par {value; _} =
|
||||
string "(" ^^ nest 1 (pp_type_expr value.inside ^^ string ")")
|
||||
|
@ -1,5 +1,5 @@
|
||||
let check_ = (p: unit): int =>
|
||||
if(Tezos.amount == 100000000mutez) {
|
||||
if (Tezos.amount == 100000000mutez) {
|
||||
42
|
||||
} else {
|
||||
0
|
||||
|
@ -1,6 +1,6 @@
|
||||
let main = (i: int) => {
|
||||
let result = 0;
|
||||
if(i == 2) {
|
||||
if (i == 2) {
|
||||
|
||||
let result = 42;
|
||||
result
|
||||
|
@ -1,5 +1,5 @@
|
||||
let main = (i: int) =>
|
||||
if(i == 2) {
|
||||
if (i == 2) {
|
||||
42
|
||||
} else {
|
||||
0
|
||||
|
@ -1,5 +1,5 @@
|
||||
let main = ((a, b): (bool, bool)) =>
|
||||
if(a == b) {
|
||||
if (a == b) {
|
||||
999
|
||||
} else {
|
||||
1
|
||||
|
@ -1,6 +1,6 @@
|
||||
type storage = unit;
|
||||
|
||||
let main = (p: unit, storage) =>
|
||||
if(true) {
|
||||
if (true) {
|
||||
failwith("This contract always fails")
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
let rec aux_simple = (i: int): int =>
|
||||
if(i < 100) {
|
||||
if (i < 100) {
|
||||
aux_simple(i + 1)
|
||||
} else {
|
||||
i
|
||||
@ -15,7 +15,7 @@ let counter = (n: int): int => {
|
||||
sum: 0
|
||||
};
|
||||
let rec aggregate = (prev: sum_aggregator): int =>
|
||||
if(prev.counter <= n) {
|
||||
if (prev.counter <= n) {
|
||||
|
||||
|
||||
aggregate({
|
||||
@ -29,7 +29,7 @@ let counter = (n: int): int => {
|
||||
};
|
||||
|
||||
let rec aux_nest = (prev: sum_aggregator): sum_aggregator =>
|
||||
if(prev.counter < 100) {
|
||||
if (prev.counter < 100) {
|
||||
|
||||
let sum: int = prev.sum + aux_simple(prev.counter);
|
||||
aux_nest({counter: prev.counter + 1, sum: sum })
|
||||
|
@ -33,7 +33,7 @@ let check_message = ((param, s): (check_message_pt, storage))
|
||||
: return => {
|
||||
let message: message = param.message;
|
||||
let s =
|
||||
if(param.counter != s.counter) {
|
||||
if (param.counter != s.counter) {
|
||||
(failwith("Counters does not match") : storage)
|
||||
} else {
|
||||
|
||||
@ -47,10 +47,10 @@ let check_message = ((param, s): (check_message_pt, storage))
|
||||
switch(keys) {
|
||||
| [] => vk
|
||||
| [key, ...keys] =>
|
||||
if(pkh_sig[0] == Crypto.hash_key(key)) {
|
||||
if (pkh_sig[0] == Crypto.hash_key(key)) {
|
||||
|
||||
let valid =
|
||||
if(
|
||||
if (
|
||||
Crypto.check(key, pkh_sig[1], packed_payload)) {
|
||||
valid + 1n
|
||||
} else {
|
||||
@ -64,7 +64,7 @@ let check_message = ((param, s): (check_message_pt, storage))
|
||||
};
|
||||
let (valid, keys) =
|
||||
List.fold(aux, param.signatures, (valid, keys));
|
||||
if(valid < s.threshold) {
|
||||
if (valid < s.threshold) {
|
||||
|
||||
(failwith("Not enough signatures passed the check")
|
||||
: storage)
|
||||
|
@ -1,7 +1,7 @@
|
||||
type f = int;
|
||||
|
||||
let a = (b: f) => {
|
||||
if(b == 2) {
|
||||
if (b == 2) {
|
||||
3
|
||||
} else {
|
||||
4
|
||||
|
@ -11,7 +11,7 @@ let donate = ((p, s): (unit, storage))
|
||||
|
||||
let distribute = ((p, s): ((unit => list(operation)),
|
||||
storage)): (list(operation), storage) => {
|
||||
if(Tezos.sender == s) {
|
||||
if (Tezos.sender == s) {
|
||||
(p(()), s)
|
||||
} else {
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
let rec sum = ((n, acc): (int, int)): int =>
|
||||
if(n < 1) {
|
||||
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) {
|
||||
if (n < 2) {
|
||||
n_1
|
||||
} else {
|
||||
fibo((n - 1, n_1 + n_0, n_1))
|
||||
|
@ -54,7 +54,7 @@ let s = {
|
||||
let t = (((((((2)))))));
|
||||
|
||||
let u =
|
||||
if(true) {
|
||||
if (true) {
|
||||
1
|
||||
} else {
|
||||
2
|
||||
|
Loading…
Reference in New Issue
Block a user