mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Types printer: use commas rather than * for tuples
This commit is contained in:
parent
69e862a9d1
commit
23b196aace
@ -102,7 +102,7 @@ let rec typ_gen
|
||||
Format.pp_open_hvbox fmt 2;
|
||||
pp_color_string (List.hd colors) fmt "(";
|
||||
(Format.pp_print_list
|
||||
~pp_sep:(fun fmt () -> Format.fprintf fmt " %a@ " op_style "*")
|
||||
~pp_sep:(fun fmt () -> Format.fprintf fmt "%a@ " op_style ",")
|
||||
(typ ~colors:(List.tl colors)))
|
||||
fmt ts;
|
||||
Format.pp_close_box fmt ();
|
||||
|
@ -76,14 +76,14 @@ let scope S (x: integer|internal|output) =
|
||||
10.
|
||||
map (λ (i: integer) → to_rat i) [1; 2; 3])
|
||||
= 3.;
|
||||
assert (let weights : list of (integer * decimal) =
|
||||
assert (let weights : list of (integer, decimal) =
|
||||
map (λ (i: integer) →
|
||||
(i, let i1 : integer = i in
|
||||
to_rat ((2 - i1) * (2 - i1))))
|
||||
[1; 2; 3]
|
||||
in
|
||||
reduce
|
||||
(λ (x1: (integer * decimal)) (x2: (integer * decimal)) →
|
||||
(λ (x1: (integer, decimal)) (x2: (integer, decimal)) →
|
||||
if x1.1 < x2.1 then x1 else x2)
|
||||
let i : integer = 42 in
|
||||
(i, let i1 : integer = i in
|
||||
|
@ -34,7 +34,7 @@ let topval closure_f : (closure_env, integer) → integer =
|
||||
if (from_closure_env env).0 then y else - y
|
||||
let scope S (S_in: S_in {x_in: bool}): S {z: integer} =
|
||||
let get x : bool = S_in.x_in in
|
||||
let set f : ((closure_env, integer) → integer * closure_env) =
|
||||
let set f : ((closure_env, integer) → integer, closure_env) =
|
||||
(closure_f, to_closure_env (x))
|
||||
in
|
||||
let set z : integer = f.0 f.1 -1 in
|
||||
|
@ -29,7 +29,7 @@ let scope S (S_in: S_in {x_in: list of integer}): S {y: integer} =
|
||||
let get x : list of integer = S_in.x_in in
|
||||
let set y : integer =
|
||||
(reduce
|
||||
(λ (x1: (integer * integer)) (x2: (integer * integer)) →
|
||||
(λ (x1: (integer, integer)) (x2: (integer, integer)) →
|
||||
if x1.1 < x2.1 then x1 else x2)
|
||||
(-1, -1)
|
||||
map (λ (potential_max: integer) → (potential_max, potential_max)) x).0
|
||||
@ -60,7 +60,7 @@ let scope S (S_in: S_in {x_in: list of integer}): S {y: integer} =
|
||||
(λ () → true)
|
||||
(λ () →
|
||||
ESome
|
||||
(let weights : list of (integer * integer) =
|
||||
(let weights : list of (integer, integer) =
|
||||
map (λ (potential_max: integer) →
|
||||
(potential_max,
|
||||
let potential_max1 : integer = potential_max in
|
||||
@ -68,7 +68,7 @@ let scope S (S_in: S_in {x_in: list of integer}): S {y: integer} =
|
||||
x
|
||||
in
|
||||
reduce
|
||||
(λ (x1: (integer * integer)) (x2: (integer * integer)) →
|
||||
(λ (x1: (integer, integer)) (x2: (integer, integer)) →
|
||||
if x1.1 < x2.1 then x1 else x2)
|
||||
let potential_max : integer = -1 in
|
||||
(potential_max,
|
||||
|
@ -25,17 +25,17 @@ $ catala Typecheck --check-invariants
|
||||
$ catala Lcalc --avoid-exceptions -O --closure-conversion
|
||||
type Eoption = | ENone of unit | ESome of any
|
||||
type S_in = { x_in: bool; }
|
||||
type S = { f: ((closure_env, integer) → integer * closure_env); }
|
||||
type S = { f: ((closure_env, integer) → integer, closure_env); }
|
||||
|
||||
let topval closure_f : (closure_env, integer) → integer =
|
||||
λ (env: closure_env) (y: integer) →
|
||||
if (from_closure_env env).0 then y else - y
|
||||
let scope S
|
||||
(S_in: S_in {x_in: bool})
|
||||
: S {f: ((closure_env, integer) → integer * closure_env)}
|
||||
: S {f: ((closure_env, integer) → integer, closure_env)}
|
||||
=
|
||||
let get x : bool = S_in.x_in in
|
||||
let set f : ((closure_env, integer) → integer * closure_env) =
|
||||
let set f : ((closure_env, integer) → integer, closure_env) =
|
||||
(closure_f, to_closure_env (x))
|
||||
in
|
||||
return { S f = f; }
|
||||
|
@ -32,11 +32,11 @@ $ catala Typecheck --check-invariants
|
||||
```catala-test-inline
|
||||
$ catala Lcalc -s T --avoid-exceptions -O --closure-conversion
|
||||
let scope T (T_in: T_in): T {y: integer} =
|
||||
let set s : S {f: ((closure_env, integer) → integer * closure_env)} =
|
||||
let set s : S {f: ((closure_env, integer) → integer, closure_env)} =
|
||||
{ S f = (closure_s, to_closure_env ()); }
|
||||
in
|
||||
let set y : integer =
|
||||
let code_and_env : ((closure_env, integer) → integer * closure_env) =
|
||||
let code_and_env : ((closure_env, integer) → integer, closure_env) =
|
||||
s.f
|
||||
in
|
||||
code_and_env.0 code_and_env.1 2
|
||||
|
@ -56,20 +56,20 @@ $ catala Typecheck --check-invariants
|
||||
$ catala Lcalc --avoid-exceptions -O --closure-conversion
|
||||
type Eoption = | ENone of unit | ESome of any
|
||||
type Result = {
|
||||
r: ((closure_env, integer) → integer * closure_env);
|
||||
r: ((closure_env, integer) → integer, closure_env);
|
||||
q: integer;
|
||||
}
|
||||
type SubFoo1_in = { x_in: integer; }
|
||||
type SubFoo1 = {
|
||||
x: integer;
|
||||
y: ((closure_env, integer) → integer * closure_env);
|
||||
y: ((closure_env, integer) → integer, closure_env);
|
||||
}
|
||||
type SubFoo2_in = { x1_in: integer; x2_in: integer; }
|
||||
type SubFoo2 = {
|
||||
x1: integer;
|
||||
y: ((closure_env, integer) → integer * closure_env);
|
||||
y: ((closure_env, integer) → integer, closure_env);
|
||||
}
|
||||
type Foo_in = { b_in: ((closure_env, unit) → eoption bool * closure_env); }
|
||||
type Foo_in = { b_in: ((closure_env, unit) → eoption bool, closure_env); }
|
||||
type Foo = { z: integer; }
|
||||
|
||||
let topval closure_y : (closure_env, integer) → integer =
|
||||
@ -79,49 +79,49 @@ let scope SubFoo1
|
||||
(SubFoo1_in: SubFoo1_in {x_in: integer})
|
||||
: SubFoo1 {
|
||||
x: integer;
|
||||
y: ((closure_env, integer) → integer * closure_env)
|
||||
y: ((closure_env, integer) → integer, closure_env)
|
||||
}
|
||||
=
|
||||
let get x : integer = SubFoo1_in.x_in in
|
||||
let set y : ((closure_env, integer) → integer * closure_env) =
|
||||
let set y : ((closure_env, integer) → integer, closure_env) =
|
||||
(closure_y, to_closure_env (x))
|
||||
in
|
||||
return { SubFoo1 x = x; y = y; }
|
||||
let topval closure_y : (closure_env, integer) → integer =
|
||||
λ (env: closure_env) (z: integer) →
|
||||
let env1 : (integer * integer) = from_closure_env env in
|
||||
let env1 : (integer, integer) = from_closure_env env in
|
||||
((env1.1 + env1.0 + z))
|
||||
let scope SubFoo2
|
||||
(SubFoo2_in: SubFoo2_in {x1_in: integer; x2_in: integer})
|
||||
: SubFoo2 {
|
||||
x1: integer;
|
||||
y: ((closure_env, integer) → integer * closure_env)
|
||||
y: ((closure_env, integer) → integer, closure_env)
|
||||
}
|
||||
=
|
||||
let get x1 : integer = SubFoo2_in.x1_in in
|
||||
let get x2 : integer = SubFoo2_in.x2_in in
|
||||
let set y : ((closure_env, integer) → integer * closure_env) =
|
||||
let set y : ((closure_env, integer) → integer, closure_env) =
|
||||
(closure_y, to_closure_env (x2, x1))
|
||||
in
|
||||
return { SubFoo2 x1 = x1; y = y; }
|
||||
let topval closure_r : (closure_env, integer) → integer =
|
||||
λ (env: closure_env) (param0: integer) →
|
||||
let code_and_env : ((closure_env, integer) → integer * closure_env) =
|
||||
let code_and_env : ((closure_env, integer) → integer, closure_env) =
|
||||
(from_closure_env env).0.y
|
||||
in
|
||||
code_and_env.0 code_and_env.1 param0
|
||||
let topval closure_r : (closure_env, integer) → integer =
|
||||
λ (env: closure_env) (param0: integer) →
|
||||
let code_and_env : ((closure_env, integer) → integer * closure_env) =
|
||||
let code_and_env : ((closure_env, integer) → integer, closure_env) =
|
||||
(from_closure_env env).0.y
|
||||
in
|
||||
code_and_env.0 code_and_env.1 param0
|
||||
let scope Foo
|
||||
(Foo_in:
|
||||
Foo_in {b_in: ((closure_env, unit) → eoption bool * closure_env)})
|
||||
Foo_in {b_in: ((closure_env, unit) → eoption bool, closure_env)})
|
||||
: Foo {z: integer}
|
||||
=
|
||||
let get b : ((closure_env, unit) → eoption bool * closure_env) =
|
||||
let get b : ((closure_env, unit) → eoption bool, closure_env) =
|
||||
Foo_in.b_in
|
||||
in
|
||||
let set b : bool =
|
||||
@ -133,7 +133,7 @@ let scope Foo
|
||||
in
|
||||
let set r :
|
||||
Result {
|
||||
r: ((closure_env, integer) → integer * closure_env);
|
||||
r: ((closure_env, integer) → integer, closure_env);
|
||||
q: integer
|
||||
} =
|
||||
if b then
|
||||
@ -152,7 +152,7 @@ let scope Foo
|
||||
{ Result r = f.y; q = f.x1; }
|
||||
in
|
||||
let set z : integer =
|
||||
let code_and_env : ((closure_env, integer) → integer * closure_env) =
|
||||
let code_and_env : ((closure_env, integer) → integer, closure_env) =
|
||||
r.r
|
||||
in
|
||||
code_and_env.0 code_and_env.1 1
|
||||
|
@ -99,55 +99,55 @@ in
|
||||
let lis3 : list of money =
|
||||
[¤20.00; ¤200.00; ¤10.00; ¤23.00; ¤25.00; ¤12.00]
|
||||
in
|
||||
let grok : (decimal, money, money) → (money * decimal) =
|
||||
let grok : (decimal, money, money) → (money, decimal) =
|
||||
λ (dec: decimal) (mon1: money) (mon2: money) →
|
||||
(mon1 * dec, mon1 / mon2)
|
||||
in
|
||||
let tlist : list of (decimal * money * money) =
|
||||
let tlist : list of (decimal, money, money) =
|
||||
map2
|
||||
(λ (a: decimal) (b_c: (money * money)) → (a, b_c.0, b_c.1))
|
||||
(λ (a: decimal) (b_c: (money, money)) → (a, b_c.0, b_c.1))
|
||||
lis1
|
||||
map2 (λ (b: money) (c: money) → (b, c)) lis2 lis3
|
||||
in
|
||||
let S : S_in → S =
|
||||
λ (S_in: S_in) →
|
||||
let r1 : list of (money * decimal) =
|
||||
map (λ (x: (decimal * money * money)) → grok x.0 x.1 x.2) tlist
|
||||
let r1 : list of (money, decimal) =
|
||||
map (λ (x: (decimal, money, money)) → grok x.0 x.1 x.2) tlist
|
||||
in
|
||||
let r2 : list of (money * decimal) =
|
||||
let r2 : list of (money, decimal) =
|
||||
map2
|
||||
(λ (x: decimal) (zip: (money * money)) →
|
||||
let x1 : (decimal * money * money) = (x, zip.0, zip.1) in
|
||||
(λ (x: decimal) (zip: (money, money)) →
|
||||
let x1 : (decimal, money, money) = (x, zip.0, zip.1) in
|
||||
grok x1.0 x1.1 x1.2)
|
||||
lis1
|
||||
map2 (λ (x: money) (zip: money) → (x, zip)) lis2 lis3
|
||||
in
|
||||
let r3 : list of (money * decimal) =
|
||||
let r3 : list of (money, decimal) =
|
||||
map2
|
||||
(λ (x: decimal) (y_z: (money * money)) →
|
||||
let x_y_z : (decimal * money * money) = (x, y_z.0, y_z.1) in
|
||||
(λ (x: decimal) (y_z: (money, money)) →
|
||||
let x_y_z : (decimal, money, money) = (x, y_z.0, y_z.1) in
|
||||
grok x_y_z.0 x_y_z.1 x_y_z.2)
|
||||
lis1
|
||||
map2 (λ (y: money) (z: money) → (y, z)) lis2 lis3
|
||||
in
|
||||
let r4 : list of (money * decimal) =
|
||||
map (λ (x_y_z: (decimal * money * money)) →
|
||||
let r4 : list of (money, decimal) =
|
||||
map (λ (x_y_z: (decimal, money, money)) →
|
||||
(x_y_z.1 * x_y_z.0, x_y_z.1 / x_y_z.2))
|
||||
tlist
|
||||
in
|
||||
let r5 : list of (money * decimal) =
|
||||
let r5 : list of (money, decimal) =
|
||||
map2
|
||||
(λ (x: decimal) (y_z: (money * money)) →
|
||||
let x_y_z : (decimal * money * money) = (x, y_z.0, y_z.1) in
|
||||
(λ (x: decimal) (y_z: (money, money)) →
|
||||
let x_y_z : (decimal, money, money) = (x, y_z.0, y_z.1) in
|
||||
(x_y_z.1 * x_y_z.0, x_y_z.1 / x_y_z.2))
|
||||
lis1
|
||||
map2 (λ (y: money) (z: money) → (y, z)) lis2 lis3
|
||||
in
|
||||
let r6 : list of (money * decimal) =
|
||||
let r6 : list of (money, decimal) =
|
||||
map2
|
||||
(λ (xy: (decimal * money)) (z: money) →
|
||||
let xy_z : ((decimal * money) * money) = (xy, z) in
|
||||
let xy1 : (decimal * money) = xy_z.0 in
|
||||
(λ (xy: (decimal, money)) (z: money) →
|
||||
let xy_z : ((decimal, money), money) = (xy, z) in
|
||||
let xy1 : (decimal, money) = xy_z.0 in
|
||||
let z1 : money = xy_z.1 in
|
||||
(xy1.1 * xy1.0, xy1.1 / z1))
|
||||
map2 (λ (x: decimal) (y: money) → (x, y)) lis1 lis2
|
||||
|
Loading…
Reference in New Issue
Block a user