Improve ReasonLIGO pretty printer output.
This commit is contained in:
parent
63086db0f1
commit
cb39217c8c
@ -48,6 +48,7 @@ and pp_let_binding let_ (binding : let_binding) =
|
|||||||
in
|
in
|
||||||
let rhs = pp_expr let_rhs in
|
let rhs = pp_expr let_rhs in
|
||||||
match let_rhs with
|
match let_rhs with
|
||||||
|
| EFun _
|
||||||
| ESeq _
|
| ESeq _
|
||||||
| ERecord _ -> lhs ^^ rhs
|
| ERecord _ -> lhs ^^ rhs
|
||||||
| _ -> prefix 2 0 lhs rhs
|
| _ -> prefix 2 0 lhs rhs
|
||||||
@ -130,7 +131,7 @@ and pp_field_pattern {value; _} =
|
|||||||
|
|
||||||
and pp_ptyped {value; _} =
|
and pp_ptyped {value; _} =
|
||||||
let {pattern; type_expr; _} = value in
|
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 =
|
and pp_type_decl decl =
|
||||||
let {name; type_expr; _} = decl.value in
|
let {name; type_expr; _} = decl.value in
|
||||||
@ -374,7 +375,7 @@ and pp_fun {value; _} =
|
|||||||
match lhs_type with
|
match lhs_type with
|
||||||
None -> empty
|
None -> empty
|
||||||
| Some (_,e) ->
|
| 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
|
in
|
||||||
match body with
|
match body with
|
||||||
| ESeq _ -> string "(" ^^ binders ^^ string ")" ^^ annot ^^ string " => " ^^ pp_expr body
|
| ESeq _ -> string "(" ^^ binders ^^ string ")" ^^ annot ^^ string " => " ^^ pp_expr body
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
let main =
|
let main = (p: key_hash): address => {
|
||||||
(p: key_hash): address => {
|
|
||||||
let c: contract(unit) = Tezos.implicit_account(p);
|
let c: contract(unit) = Tezos.implicit_account(p);
|
||||||
Tezos.address(c)
|
Tezos.address(c)
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
let check_ =
|
let check_ = (p: unit): int =>
|
||||||
(p: unit): int =>
|
|
||||||
if(Tezos.amount == 100000000mutez) {
|
if(Tezos.amount == 100000000mutez) {
|
||||||
42
|
42
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
let main =
|
let main = (parameter: int, storage: address) =>
|
||||||
(parameter: int, storage: address) =>
|
|
||||||
([] : list(operation), "KT1badaddr" : address);
|
([] : list(operation), "KT1badaddr" : address);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
type storage = tez;
|
type storage = tez;
|
||||||
|
|
||||||
let main2 =
|
let main2 = (p: unit, s: storage) =>
|
||||||
(p: unit, s: storage) =>
|
|
||||||
([] : list(operation), Tezos.balance);
|
([] : list(operation), Tezos.balance);
|
||||||
|
|
||||||
let main = (x: (unit, storage)) => main2(x[0], x[1]);
|
let main = (x: (unit, storage)) => main2(x[0], x[1]);
|
||||||
|
@ -1,17 +1,14 @@
|
|||||||
let id_string =
|
let id_string = (p: string): option(string) => {
|
||||||
(p: string): option(string) => {
|
|
||||||
let packed: bytes = Bytes.pack(p);
|
let packed: bytes = Bytes.pack(p);
|
||||||
((Bytes.unpack(packed)) : option(string))
|
((Bytes.unpack(packed)) : option(string))
|
||||||
};
|
};
|
||||||
|
|
||||||
let id_int =
|
let id_int = (p: int): option(int) => {
|
||||||
(p: int): option(int) => {
|
|
||||||
let packed: bytes = Bytes.pack(p);
|
let packed: bytes = Bytes.pack(p);
|
||||||
((Bytes.unpack(packed)) : option(int))
|
((Bytes.unpack(packed)) : option(int))
|
||||||
};
|
};
|
||||||
|
|
||||||
let id_address =
|
let id_address = (p: address): option(address) => {
|
||||||
(p: address): option(address) => {
|
|
||||||
let packed: bytes = Bytes.pack(p);
|
let packed: bytes = Bytes.pack(p);
|
||||||
((Bytes.unpack(packed)) : option(address))
|
((Bytes.unpack(packed)) : option(address))
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
let check_signature =
|
let check_signature = (param: (key, signature, bytes)): bool => {
|
||||||
(param: (key, signature, bytes)): bool => {
|
|
||||||
let (pk, signed, msg) = param;
|
let (pk, signed, msg) = param;
|
||||||
Crypto.check(pk, signed, msg)
|
Crypto.check(pk, signed, msg)
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
let test =
|
let test = (k: int): int => {
|
||||||
(k: int): int => {
|
|
||||||
let j: int = k + 5;
|
let j: int = k + 5;
|
||||||
let close: (int => int) = (i: int) => i + j;
|
let close: (int => int) = (i: int) => i + j;
|
||||||
let j: int = 20;
|
let j: int = 20;
|
||||||
close(20)
|
close(20)
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
let main =
|
let main = (i: int) => {
|
||||||
(i: int) => {
|
|
||||||
let result = 0;
|
let result = 0;
|
||||||
if(i == 2) {
|
if(i == 2) {
|
||||||
|
|
||||||
@ -10,4 +9,4 @@ let main =
|
|||||||
let result = 0;
|
let result = 0;
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
let main =
|
let main = (i: int) =>
|
||||||
(i: int) =>
|
|
||||||
if(i == 2) {
|
if(i == 2) {
|
||||||
42
|
42
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
type storage = int;
|
type storage = int;
|
||||||
|
|
||||||
let main =
|
let main = ((p, s): (int, storage))
|
||||||
((p, s): (int, storage)): (list(operation), storage) =>
|
: (list(operation), storage) =>
|
||||||
([] : list(operation), p + s);
|
([] : list(operation), p + s);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
type foo = Bar(int) | Baz;
|
type foo = Bar(int) | Baz;
|
||||||
|
|
||||||
let main =
|
let main = (f: foo): int =>
|
||||||
(f: foo): int =>
|
|
||||||
switch(f) {
|
switch(f) {
|
||||||
| Bar(i) => i
|
| Bar(i) => i
|
||||||
| Baz => (-1)
|
| Baz => (-1)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
let main =
|
let main = ((a, b): (bool, bool)) =>
|
||||||
((a, b): (bool, bool)) =>
|
|
||||||
if(a == b) {
|
if(a == b) {
|
||||||
999
|
999
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
type storage = unit;
|
type storage = unit;
|
||||||
|
|
||||||
let main =
|
let main = (p: unit, storage) =>
|
||||||
(p: unit, storage) =>
|
|
||||||
if(true) {
|
if(true) {
|
||||||
failwith("This contract always fails")
|
failwith("This contract always fails")
|
||||||
};
|
};
|
||||||
|
@ -1,30 +1,25 @@
|
|||||||
let foobar =
|
let foobar = (i: int): int => {
|
||||||
(i: int): int => {
|
|
||||||
let foo: int => int = (i: int) => i;
|
let foo: int => int = (i: int) => i;
|
||||||
let bar: ((int => int) => int) =
|
let bar: ((int => int) => int) = (f: (int => int)) => f(i);
|
||||||
(f: (int => int)) => f(i);
|
|
||||||
bar(foo)
|
bar(foo)
|
||||||
};
|
};
|
||||||
|
|
||||||
let higher2 =
|
let higher2 = (i: int, f: (int => int)): int => {
|
||||||
(i: int, f: (int => int)): int => {
|
|
||||||
let ii: int = f(i);
|
let ii: int = f(i);
|
||||||
ii
|
ii
|
||||||
};
|
};
|
||||||
|
|
||||||
let foobar2 =
|
let foobar2 = (i: int): int => {
|
||||||
(i: int): int => {
|
|
||||||
let foo2: int => int = (i: int) => i;
|
let foo2: int => int = (i: int) => i;
|
||||||
higher2(i, foo2)
|
higher2(i, foo2)
|
||||||
};
|
};
|
||||||
|
|
||||||
let a: int = 0;
|
let a: int = 0;
|
||||||
|
|
||||||
let foobar3 =
|
let foobar3 = (i: int): int => {
|
||||||
(i: int): int => {
|
|
||||||
let foo2: int => int = (i: int) => a + i;
|
let foo2: int => int = (i: int) => a + i;
|
||||||
higher2(i, foo2)
|
higher2(i, foo2)
|
||||||
};
|
};
|
||||||
|
|
||||||
let f = (i: int): int => i;
|
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 foobar4 = (i: int): int => g(g(i));
|
||||||
|
|
||||||
let higher3 =
|
let higher3 = (i: int, f: (int => int), g: (int => int))
|
||||||
(i: int, f: (int => int), g: (int => int)): int => {
|
: int => {
|
||||||
let ii: int = f(g(i));
|
let ii: int = f(g(i));
|
||||||
ii
|
ii
|
||||||
};
|
};
|
||||||
|
|
||||||
let foobar5 =
|
let foobar5 = (i: int): int => {
|
||||||
(i: int): int => {
|
|
||||||
let a: int = 0;
|
let a: int = 0;
|
||||||
let foo: int => int = (i: int) => a + i;
|
let foo: int => int = (i: int) => a + i;
|
||||||
let goo: int => int = (i: int) => foo(i);
|
let goo: int => int = (i: int) => foo(i);
|
||||||
higher3(i, foo, goo)
|
higher3(i, foo, goo)
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
let main =
|
let main = (kh: key_hash): contract(unit) =>
|
||||||
(kh: key_hash): contract(unit) =>
|
|
||||||
Tezos.implicit_account(kh);
|
Tezos.implicit_account(kh);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
let check_hash_key =
|
let check_hash_key = (kh1_k2: (key_hash, key))
|
||||||
(kh1_k2: (key_hash, key)): (bool, key_hash) => {
|
: (bool, key_hash) => {
|
||||||
let (kh1, k2) = kh1_k2;
|
let (kh1, k2) = kh1_k2;
|
||||||
let kh2: key_hash = Crypto.hash_key(k2);
|
let kh2: key_hash = Crypto.hash_key(k2);
|
||||||
((kh1 == kh2), kh2)
|
((kh1 == kh2), kh2)
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
type storage = unit;
|
type storage = unit;
|
||||||
|
|
||||||
let main =
|
let main = ((p, s): (unit, storage)): unit =>
|
||||||
((p, s): (unit, storage)): unit =>
|
|
||||||
(((useless: unit)) => ())(());
|
(((useless: unit)) => ())(());
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
type storage = unit;
|
type storage = unit;
|
||||||
|
|
||||||
let main =
|
let main = ((a, s): (unit, storage)): unit =>
|
||||||
((a, s): (unit, storage)): unit =>
|
|
||||||
((f: (unit => unit)) => f(()))((useless: unit) => unit);
|
((f: (unit => unit)) => f(()))((useless: unit) => unit);
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
type storage = (int, int);
|
type storage = (int, int);
|
||||||
|
|
||||||
let main =
|
let main = (n: (int, storage)): (list(operation), storage) => {
|
||||||
(n: (int, storage)): (list(operation), storage) => {
|
|
||||||
let x: (int, int) = {
|
let x: (int, int) = {
|
||||||
let x: int = 7;
|
let x: int = 7;
|
||||||
(x + n[0], n[1][0] + n[1][1])
|
(x + n[0], n[1][0] + n[1][1])
|
||||||
};
|
};
|
||||||
([] : list(operation), x)
|
([] : list(operation), x)
|
||||||
};
|
};
|
||||||
|
|
||||||
let f0 = (a: string) => true;
|
let f0 = (a: string) => true;
|
||||||
|
|
||||||
@ -15,8 +14,7 @@ let f1 = (a: string) => true;
|
|||||||
|
|
||||||
let f2 = (a: string) => true;
|
let f2 = (a: string) => true;
|
||||||
|
|
||||||
let letin_nesting =
|
let letin_nesting = (_: unit) => {
|
||||||
(_: unit) => {
|
|
||||||
let s = "test";
|
let s = "test";
|
||||||
let p0 = f0(s);
|
let p0 = f0(s);
|
||||||
assert(p0);
|
assert(p0);
|
||||||
@ -25,11 +23,10 @@ let letin_nesting =
|
|||||||
let p2 = f2(s);
|
let p2 = f2(s);
|
||||||
assert(p2);
|
assert(p2);
|
||||||
s
|
s
|
||||||
};
|
};
|
||||||
|
|
||||||
let letin_nesting2 =
|
let letin_nesting2 = (x: int) => {
|
||||||
(x: int) => {
|
|
||||||
let y = 2;
|
let y = 2;
|
||||||
let z = 3;
|
let z = 3;
|
||||||
x + y + z
|
x + y + z
|
||||||
};
|
};
|
||||||
|
@ -10,30 +10,26 @@ let y: list(int) = [3, 4, 5];
|
|||||||
|
|
||||||
let z: list(int) = [2, ...y];
|
let z: list(int) = [2, ...y];
|
||||||
|
|
||||||
let main =
|
let main = ((action, s): (parameter, storage)): return => {
|
||||||
((action, s): (parameter, storage)): return => {
|
|
||||||
let storage =
|
let storage =
|
||||||
switch(action) {
|
switch(action) {
|
||||||
| [] => s
|
| [] => s
|
||||||
| [hd, ...tl] => (s[0] + hd, tl)
|
| [hd, ...tl] => (s[0] + hd, tl)
|
||||||
};
|
};
|
||||||
([] : list(operation), storage)
|
([] : list(operation), storage)
|
||||||
};
|
};
|
||||||
|
|
||||||
let size_ = (s: list(int)): nat => List.length(s);
|
let size_ = (s: list(int)): nat => List.length(s);
|
||||||
|
|
||||||
let fold_op =
|
let fold_op = (s: list(int)): int => {
|
||||||
(s: list(int)): int => {
|
|
||||||
let aggregate = (t: (int, int)) => t[0] + t[1];
|
let aggregate = (t: (int, int)) => t[0] + t[1];
|
||||||
List.fold(aggregate, s, 10)
|
List.fold(aggregate, s, 10)
|
||||||
};
|
};
|
||||||
|
|
||||||
let map_op =
|
let map_op = (s: list(int)): list(int) =>
|
||||||
(s: list(int)): list(int) =>
|
|
||||||
List.map((cur: int) => cur + 1, s);
|
List.map((cur: int) => cur + 1, s);
|
||||||
|
|
||||||
let iter_op =
|
let iter_op = (s: list(int)): unit => {
|
||||||
(s: list(int)): unit => {
|
|
||||||
let do_nothing = (useless: int) => unit;
|
let do_nothing = (useless: int) => unit;
|
||||||
List.iter(do_nothing, s)
|
List.iter(do_nothing, s)
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
let rec aux_simple =
|
let rec aux_simple = (i: int): int =>
|
||||||
(i: int): int =>
|
|
||||||
if(i < 100) {
|
if(i < 100) {
|
||||||
aux_simple(i + 1)
|
aux_simple(i + 1)
|
||||||
} else {
|
} else {
|
||||||
@ -10,14 +9,12 @@ let counter_simple = (n: int): int => aux_simple(n);
|
|||||||
|
|
||||||
type sum_aggregator = {counter: int, sum: int };
|
type sum_aggregator = {counter: int, sum: int };
|
||||||
|
|
||||||
let counter =
|
let counter = (n: int): int => {
|
||||||
(n: int): int => {
|
|
||||||
let initial: sum_aggregator = {
|
let initial: sum_aggregator = {
|
||||||
counter: 0,
|
counter: 0,
|
||||||
sum: 0
|
sum: 0
|
||||||
};
|
};
|
||||||
let rec aggregate =
|
let rec aggregate = (prev: sum_aggregator): int =>
|
||||||
(prev: sum_aggregator): int =>
|
|
||||||
if(prev.counter <= n) {
|
if(prev.counter <= n) {
|
||||||
|
|
||||||
|
|
||||||
@ -29,10 +26,9 @@ let counter =
|
|||||||
prev.sum
|
prev.sum
|
||||||
};
|
};
|
||||||
aggregate(initial)
|
aggregate(initial)
|
||||||
};
|
};
|
||||||
|
|
||||||
let rec aux_nest =
|
let rec aux_nest = (prev: sum_aggregator): sum_aggregator =>
|
||||||
(prev: sum_aggregator): sum_aggregator =>
|
|
||||||
if(prev.counter < 100) {
|
if(prev.counter < 100) {
|
||||||
|
|
||||||
let sum: int = prev.sum + aux_simple(prev.counter);
|
let sum: int = prev.sum + aux_simple(prev.counter);
|
||||||
@ -41,12 +37,11 @@ let rec aux_nest =
|
|||||||
({counter: prev.counter, sum: prev.sum })
|
({counter: prev.counter, sum: prev.sum })
|
||||||
};
|
};
|
||||||
|
|
||||||
let counter_nest =
|
let counter_nest = (n: int): int => {
|
||||||
(n: int): int => {
|
|
||||||
let initial: sum_aggregator = {
|
let initial: sum_aggregator = {
|
||||||
counter: 0,
|
counter: 0,
|
||||||
sum: 0
|
sum: 0
|
||||||
};
|
};
|
||||||
let out: sum_aggregator = aux_nest(initial);
|
let out: sum_aggregator = aux_nest(initial);
|
||||||
out.sum
|
out.sum
|
||||||
};
|
};
|
||||||
|
@ -12,23 +12,20 @@ let map1: foobar =
|
|||||||
|
|
||||||
let map2: foobar = Map.literal([(23, 0), (42, 0)]);
|
let map2: foobar = Map.literal([(23, 0), (42, 0)]);
|
||||||
|
|
||||||
let set_ =
|
let set_ = (n: int, m: foobar): foobar =>
|
||||||
(n: int, m: foobar): foobar => Map.update(23, Some (n), m);
|
Map.update(23, Some (n), m);
|
||||||
|
|
||||||
let add = (n: int, m: foobar): foobar => Map.add(23, n, m);
|
let add = (n: int, m: foobar): foobar => Map.add(23, n, m);
|
||||||
|
|
||||||
let rm = (m: foobar): foobar => Map.remove(42, m);
|
let rm = (m: foobar): foobar => Map.remove(42, m);
|
||||||
|
|
||||||
let patch_ =
|
let patch_ = (m: foobar): foobar =>
|
||||||
(m: foobar): foobar =>
|
|
||||||
Map.literal([(0, 5), (1, 6), (2, 7)]);
|
Map.literal([(0, 5), (1, 6), (2, 7)]);
|
||||||
|
|
||||||
let patch_empty =
|
let patch_empty = (m: foobar): foobar =>
|
||||||
(m: foobar): foobar =>
|
|
||||||
Map.literal([(0, 0), (1, 1), (2, 2)]);
|
Map.literal([(0, 0), (1, 1), (2, 2)]);
|
||||||
|
|
||||||
let patch_deep =
|
let patch_deep = (m: (foobar, nat)): (foobar, nat) =>
|
||||||
(m: (foobar, nat)): (foobar, nat) =>
|
|
||||||
(Map.literal([(0, 0), (1, 9), (2, 2)]), 10n);
|
(Map.literal([(0, 0), (1, 9), (2, 2)]), 10n);
|
||||||
|
|
||||||
let size_ = (m: foobar): nat => Map.size(m);
|
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 mem = (km: (int, foobar)): bool => Map.mem(km[0], km[1]);
|
||||||
|
|
||||||
let iter_op =
|
let iter_op = (m: foobar): unit => {
|
||||||
(m: foobar): unit => {
|
|
||||||
let assert_eq = (i: int, j: int) => assert(i == j);
|
let assert_eq = (i: int, j: int) => assert(i == j);
|
||||||
Map.iter(assert_eq, m)
|
Map.iter(assert_eq, m)
|
||||||
};
|
};
|
||||||
|
|
||||||
let map_op =
|
let map_op = (m: foobar): foobar => {
|
||||||
(m: foobar): foobar => {
|
|
||||||
let increment = (z: int, j: int) => j + 1;
|
let increment = (z: int, j: int) => j + 1;
|
||||||
Map.map(increment, m)
|
Map.map(increment, m)
|
||||||
};
|
};
|
||||||
|
|
||||||
let fold_op =
|
let fold_op = (m: foobar): foobar => {
|
||||||
(m: foobar): foobar => {
|
let aggregate = (i: int, j: (int, int)) => i + j[0] + j[1];
|
||||||
let aggregate =
|
|
||||||
(i: int, j: (int, int)) => i + j[0] + j[1];
|
|
||||||
Map.fold(aggregate, m, 10)
|
Map.fold(aggregate, m, 10)
|
||||||
};
|
};
|
||||||
|
|
||||||
let deep_op =
|
let deep_op = (m: foobar): foobar => {
|
||||||
(m: foobar): foobar => {
|
|
||||||
let coco = (0, m);
|
let coco = (0, m);
|
||||||
let coco = (0, Map.remove(42, coco[1]));
|
let coco = (0, Map.remove(42, coco[1]));
|
||||||
let coco = (0, Map.update(32, Some (16), coco[1]));
|
let coco = (0, Map.update(32, Some (16), coco[1]));
|
||||||
coco[1]
|
coco[1]
|
||||||
};
|
};
|
||||||
|
@ -4,12 +4,11 @@ type parameter = Add(int) | Sub(int);
|
|||||||
|
|
||||||
type return = (list(operation), storage);
|
type return = (list(operation), storage);
|
||||||
|
|
||||||
let main =
|
let main = ((action, store): (parameter, storage)) => {
|
||||||
((action, store): (parameter, storage)) => {
|
|
||||||
let store =
|
let store =
|
||||||
store + (switch(action) {
|
store + (switch(action) {
|
||||||
| Add(n) => n
|
| Add(n) => n
|
||||||
| Sub(n) => -n
|
| Sub(n) => -n
|
||||||
});
|
});
|
||||||
(([] : list(operation)), store)
|
(([] : list(operation)), store)
|
||||||
};
|
};
|
||||||
|
@ -6,12 +6,11 @@ let add = ((a: int), (b: int)) => a + b;
|
|||||||
|
|
||||||
let sub = ((a: int), (b: int)) => a - b;
|
let sub = ((a: int), (b: int)) => a - b;
|
||||||
|
|
||||||
let main =
|
let main = ((action, store): (parameter, storage)) => {
|
||||||
((action, store): (parameter, storage)) => {
|
|
||||||
let store =
|
let store =
|
||||||
switch(action) {
|
switch(action) {
|
||||||
| Increment(n) => add(store, n)
|
| Increment(n) => add(store, n)
|
||||||
| Decrement(n) => sub(store, n)
|
| Decrement(n) => sub(store, n)
|
||||||
};
|
};
|
||||||
(([] : list(operation)), store)
|
(([] : list(operation)), store)
|
||||||
};
|
};
|
||||||
|
@ -5,8 +5,7 @@ type storage = michelson_pair
|
|||||||
|
|
||||||
type return = (list(operation), storage);
|
type return = (list(operation), storage);
|
||||||
|
|
||||||
let main =
|
let main = ((action, store): (unit, storage)): return => {
|
||||||
((action, store): (unit, storage)): return => {
|
|
||||||
let foo = (3, (1, 2n));
|
let foo = (3, (1, 2n));
|
||||||
(([] : list(operation)), (foo : storage))
|
(([] : list(operation)), (foo : storage))
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
let abcde_curried =
|
let abcde_curried = (a: int, b: int, c: int, d: int, e: int)
|
||||||
(a: int, b: int, c: int, d: int, e: int): int => c + e + 3;
|
: int =>
|
||||||
|
c + e + 3;
|
||||||
|
|
||||||
let abcde =
|
let abcde = (x: (int, int, int, int, int)): int =>
|
||||||
(x: (int, int, int, int, int)): int =>
|
|
||||||
abcde_curried(x[0], x[1], x[2], x[3], x[4]);
|
abcde_curried(x[0], x[1], x[2], x[3], x[4]);
|
||||||
|
@ -29,8 +29,8 @@ type return = (list(operation), storage);
|
|||||||
|
|
||||||
type parameter = CheckMessage(check_message_pt);
|
type parameter = CheckMessage(check_message_pt);
|
||||||
|
|
||||||
let check_message =
|
let check_message = ((param, s): (check_message_pt, storage))
|
||||||
((param, s): (check_message_pt, storage)): return => {
|
: return => {
|
||||||
let message: message = param.message;
|
let message: message = param.message;
|
||||||
let s =
|
let s =
|
||||||
if(param.counter != s.counter) {
|
if(param.counter != s.counter) {
|
||||||
@ -38,15 +38,11 @@ let check_message =
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
let packed_payload: bytes =
|
let packed_payload: bytes =
|
||||||
|
|
||||||
Bytes.pack((message, param.counter, s.id, chain_id));
|
Bytes.pack((message, param.counter, s.id, chain_id));
|
||||||
let valid: nat = 0n;
|
let valid: nat = 0n;
|
||||||
let keys: authorized_keys = s.auth;
|
let keys: authorized_keys = s.auth;
|
||||||
let aux =
|
let aux = ((vk, pkh_sig): ((nat, authorized_keys),
|
||||||
((vk, pkh_sig):
|
(key_hash, signature))): (nat, authorized_keys) => {
|
||||||
((nat, authorized_keys), (key_hash, signature)))
|
|
||||||
:
|
|
||||||
(nat, authorized_keys) => {
|
|
||||||
let (valid, keys) = vk;
|
let (valid, keys) = vk;
|
||||||
switch(keys) {
|
switch(keys) {
|
||||||
| [] => vk
|
| [] => vk
|
||||||
@ -55,9 +51,7 @@ let check_message =
|
|||||||
|
|
||||||
let valid =
|
let valid =
|
||||||
if(
|
if(
|
||||||
Crypto.check(key,
|
Crypto.check(key, pkh_sig[1], packed_payload)) {
|
||||||
pkh_sig[1],
|
|
||||||
packed_payload)) {
|
|
||||||
valid + 1n
|
valid + 1n
|
||||||
} else {
|
} else {
|
||||||
(failwith("Invalid signature") : nat)
|
(failwith("Invalid signature") : nat)
|
||||||
@ -72,18 +66,16 @@ let check_message =
|
|||||||
List.fold(aux, param.signatures, (valid, keys));
|
List.fold(aux, param.signatures, (valid, keys));
|
||||||
if(valid < s.threshold) {
|
if(valid < s.threshold) {
|
||||||
|
|
||||||
(
|
(failwith("Not enough signatures passed the check")
|
||||||
failwith("Not enough signatures passed the check")
|
|
||||||
: storage)
|
: storage)
|
||||||
} else {
|
} else {
|
||||||
{...s, counter: s.counter + 1n}
|
{...s, counter: s.counter + 1n}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(message(unit), s)
|
(message(unit), s)
|
||||||
};
|
};
|
||||||
|
|
||||||
let main =
|
let main = ((action, store): (parameter, storage)): return =>
|
||||||
((action, store): (parameter, storage)): return =>
|
|
||||||
switch(action) {
|
switch(action) {
|
||||||
| CheckMessage(p) => check_message((p, store))
|
| CheckMessage(p) => check_message((p, store))
|
||||||
};
|
};
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
type f = int;
|
type f = int;
|
||||||
|
|
||||||
let a =
|
let a = (b: f) => {
|
||||||
(b: f) => {
|
|
||||||
if(b == 2) {
|
if(b == 2) {
|
||||||
3
|
3
|
||||||
} else {
|
} else {
|
||||||
4
|
4
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let c =
|
let c = (c: f) => {
|
||||||
(c: f) => {
|
|
||||||
3
|
3
|
||||||
};
|
};
|
||||||
|
@ -4,15 +4,13 @@ type parameter =
|
|||||||
Donate(unit)
|
Donate(unit)
|
||||||
| Distribute((unit => list(operation)));
|
| Distribute((unit => list(operation)));
|
||||||
|
|
||||||
let donate =
|
let donate = ((p, s): (unit, storage))
|
||||||
((p, s): (unit, storage)): (list(operation), storage) => {
|
: (list(operation), storage) => {
|
||||||
(([] : list(operation)), s)
|
(([] : list(operation)), s)
|
||||||
};
|
};
|
||||||
|
|
||||||
let distribute =
|
let distribute = ((p, s): ((unit => list(operation)),
|
||||||
((p, s): ((unit => list(operation)), storage))
|
storage)): (list(operation), storage) => {
|
||||||
:
|
|
||||||
(list(operation), storage) => {
|
|
||||||
if(Tezos.sender == s) {
|
if(Tezos.sender == s) {
|
||||||
(p(()), s)
|
(p(()), s)
|
||||||
} else {
|
} else {
|
||||||
@ -21,12 +19,12 @@ let distribute =
|
|||||||
failwith("You're not the oracle for this distribution.")
|
failwith("You're not the oracle for this distribution.")
|
||||||
: (list(operation), storage))
|
: (list(operation), storage))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let main =
|
let main = ((p, s): (parameter, storage))
|
||||||
((p, s): (parameter, storage)): (list(operation), storage) => {
|
: (list(operation), storage) => {
|
||||||
switch(p) {
|
switch(p) {
|
||||||
| Donate => donate(((), s))
|
| Donate => donate(((), s))
|
||||||
| Distribute msg => distribute((msg, s))
|
| Distribute msg => distribute((msg, s))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -24,5 +24,6 @@ let br: big_record = {a: 23, b: 23, c: 23, d: 23, e: 23 };
|
|||||||
|
|
||||||
type double_record = {inner: abc };
|
type double_record = {inner: abc };
|
||||||
|
|
||||||
let modify_inner =
|
let modify_inner = (r: double_record): double_record =>
|
||||||
(r: double_record): double_record => {...r, inner.b: 2048};
|
{...r,
|
||||||
|
inner.b: 2048};
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
let rec sum =
|
let rec sum = ((n, acc): (int, int)): int =>
|
||||||
((n, acc): (int, int)): int =>
|
|
||||||
if(n < 1) {
|
if(n < 1) {
|
||||||
acc
|
acc
|
||||||
} else {
|
} else {
|
||||||
sum((n - 1, acc + n))
|
sum((n - 1, acc + n))
|
||||||
};
|
};
|
||||||
|
|
||||||
let rec fibo =
|
let rec fibo = ((n, n_1, n_0): (int, int, int)): int =>
|
||||||
((n, n_1, n_0): (int, int, int)): int =>
|
|
||||||
if(n < 2) {
|
if(n < 2) {
|
||||||
n_1
|
n_1
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
let literal_op =
|
let literal_op = (p: unit): set(string) =>
|
||||||
(p: unit): set(string) =>
|
|
||||||
Set.literal(["foo", "bar", "foobar"]);
|
Set.literal(["foo", "bar", "foobar"]);
|
||||||
|
|
||||||
let add_op =
|
let add_op = (s: set(string)): set(string) =>
|
||||||
(s: set(string)): set(string) => Set.add("foobar", s);
|
Set.add("foobar", s);
|
||||||
|
|
||||||
let remove_op =
|
let remove_op = (s: set(string)): set(string) =>
|
||||||
(s: set(string)): set(string) => Set.remove("foobar", s);
|
Set.remove("foobar", s);
|
||||||
|
|
||||||
let remove_deep =
|
let remove_deep = (s: (set(string), nat)): set(string) =>
|
||||||
(s: (set(string), nat)): set(string) =>
|
|
||||||
Set.remove("foobar", s[0]);
|
Set.remove("foobar", s[0]);
|
||||||
|
|
||||||
let mem_op = (s: set(string)): bool => Set.mem("foobar", s);
|
let mem_op = (s: set(string)): bool => Set.mem("foobar", s);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
let main =
|
let main = (p: key_hash): list(operation) => {
|
||||||
(p: key_hash): list(operation) => {
|
|
||||||
let unused: operation = (Tezos.set_delegate(Some (p)));
|
let unused: operation = (Tezos.set_delegate(Some (p)));
|
||||||
([] : list(operation))
|
([] : list(operation))
|
||||||
};
|
};
|
||||||
|
@ -4,12 +4,11 @@ type storage = int;
|
|||||||
|
|
||||||
type return = (list(operation), storage);
|
type return = (list(operation), storage);
|
||||||
|
|
||||||
let main =
|
let main = ((action, store): (parameter, storage)): return => {
|
||||||
((action, store): (parameter, storage)): return => {
|
|
||||||
let store =
|
let store =
|
||||||
switch(action) {
|
switch(action) {
|
||||||
| Increment(n) => store + n
|
| Increment(n) => store + n
|
||||||
| Decrement(n) => store - n
|
| Decrement(n) => store - n
|
||||||
};
|
};
|
||||||
([] : list(operation), store)
|
([] : list(operation), store)
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
let sum = ((result, i): (int, int)): int => result - i;
|
let sum = ((result, i): (int, int)): int => result - i;
|
||||||
|
|
||||||
let parentheses =
|
let parentheses = (((((result, i)))): (((int, int)))): int =>
|
||||||
(((((result, i)))): (((int, int)))): int => result - i;
|
result - i;
|
||||||
|
@ -1,44 +1,40 @@
|
|||||||
type fun_type = (int, int) => int;
|
type fun_type = (int, int) => int;
|
||||||
|
|
||||||
let arguments =
|
let arguments = (b: int, c: int) => {
|
||||||
(b: int, c: int) => {
|
|
||||||
b + c
|
b + c
|
||||||
};
|
};
|
||||||
|
|
||||||
let arguments_type_def = (b: fun_type) => b(5, 3);
|
let arguments_type_def = (b: fun_type) => b(5, 3);
|
||||||
|
|
||||||
let arguments_test =
|
let arguments_test = (_: int) =>
|
||||||
(_: int) => arguments_type_def(arguments);
|
arguments_type_def(arguments);
|
||||||
|
|
||||||
type tuple_type = ((int, int)) => int;
|
type tuple_type = ((int, int)) => int;
|
||||||
|
|
||||||
let tuple =
|
let tuple = ((a, b): (int, int)) => {
|
||||||
((a, b): (int, int)) => {
|
|
||||||
a + b
|
a + b
|
||||||
};
|
};
|
||||||
|
|
||||||
let tuple_type_def = (b: tuple_type) => b((5, 3));
|
let tuple_type_def = (b: tuple_type) => b((5, 3));
|
||||||
|
|
||||||
let tuple_test = (_: int) => tuple_type_def(tuple);
|
let tuple_test = (_: int) => tuple_type_def(tuple);
|
||||||
|
|
||||||
let arguments_inline =
|
let arguments_inline = (b: int, c: int) => {
|
||||||
(b: int, c: int) => {
|
|
||||||
b + c
|
b + c
|
||||||
};
|
};
|
||||||
|
|
||||||
let arguments_type_def_inline =
|
let arguments_type_def_inline = (b: (int, int) => int) =>
|
||||||
(b: (int, int) => int) => b(5, 3);
|
b(5, 3);
|
||||||
|
|
||||||
let arguments_test_inline =
|
let arguments_test_inline = (_: int) =>
|
||||||
(_: int) => arguments_type_def_inline(arguments_inline);
|
arguments_type_def_inline(arguments_inline);
|
||||||
|
|
||||||
let tuple_inline =
|
let tuple_inline = ((a, b): (int, int)) => {
|
||||||
((a, b): (int, int)) => {
|
|
||||||
a + b
|
a + b
|
||||||
};
|
};
|
||||||
|
|
||||||
let tuple_type_def_inline =
|
let tuple_type_def_inline = (b: ((int, int)) => int) =>
|
||||||
(b: ((int, int)) => int) => b((5, 3));
|
b((5, 3));
|
||||||
|
|
||||||
let tuple_test_inline =
|
let tuple_test_inline = (_: int) =>
|
||||||
(_: int) => tuple_type_def_inline(tuple_inline);
|
tuple_type_def_inline(tuple_inline);
|
||||||
|
@ -2,7 +2,6 @@ type storage = (int, string, nat, bool);
|
|||||||
|
|
||||||
type parameter = int;
|
type parameter = int;
|
||||||
|
|
||||||
let main =
|
let main = ((p, storage): (parameter, storage)) => {
|
||||||
((p, storage): (parameter, storage)) => {
|
|
||||||
([] : list(operation), (2, "2", 2n, false))
|
([] : list(operation), (2, "2", 2n, false))
|
||||||
};
|
};
|
||||||
|
@ -6,12 +6,11 @@ let add = ((a, b): (int, int)): int => a + b;
|
|||||||
|
|
||||||
let sub = ((a, b): (int, int)): int => a - b;
|
let sub = ((a, b): (int, int)): int => a - b;
|
||||||
|
|
||||||
let main =
|
let main = ((p, storage): (parameter, storage)) => {
|
||||||
((p, storage): (parameter, storage)) => {
|
|
||||||
let storage =
|
let storage =
|
||||||
switch(p) {
|
switch(p) {
|
||||||
| Increment(n) => add((storage, n))
|
| Increment(n) => add((storage, n))
|
||||||
| Decrement(n) => sub((storage, n))
|
| Decrement(n) => sub((storage, n))
|
||||||
};
|
};
|
||||||
([] : list(operation), storage)
|
([] : list(operation), storage)
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user