Improving the printer on arrays

This commit is contained in:
Louis Gesbert 2023-10-13 17:25:21 +02:00
parent 9024cf1222
commit 1d8e3748ea
8 changed files with 53 additions and 32 deletions

View File

@ -1052,7 +1052,7 @@ module UserFacing = struct
match Mark.remove e with
| ELit l -> lit lang ppf l
| EArray l | ETuple l ->
Format.fprintf ppf "[@;<0 2>%a@;<0 -2>]"
Format.fprintf ppf "@[<hv 2>[@,@[<hov>%a@]@;<0 -2>]@]"
(Format.pp_print_list
~pp_sep:(fun ppf () -> Format.fprintf ppf ";@ ")
(value ~fallback lang))
@ -1061,10 +1061,11 @@ module UserFacing = struct
Format.fprintf ppf "@[<hv 2>%a {@ %a@;<1 -2>}@]" StructName.format name
(StructField.Map.format_bindings ~pp_sep:Format.pp_print_space
(fun ppf pp_fld e ->
Format.fprintf ppf "-- %t: %a" pp_fld (value ~fallback lang) e))
Format.fprintf ppf "@[<hov 2>-- %t:@ %a@]" pp_fld
(value ~fallback lang) e))
fields
| EInj { name = _; cons; e } ->
Format.fprintf ppf "%a %a" EnumConstructor.format cons
Format.fprintf ppf "@[<hov 2>%a@ %a@]" EnumConstructor.format cons
(value ~fallback lang) e
| EEmptyError -> Format.pp_print_string ppf "ø"
| EAbs _ -> Format.pp_print_string ppf "<function>"

View File

@ -33,8 +33,11 @@ scope B:
$ catala Interpret -s A
[RESULT] Computation successful! Results:
[RESULT]
x = [S { -- id: 0 -- income: $0.00 }; S { -- id: 1 -- income: $9.00 };
S { -- id: 2 -- income: $5.20 }]
x =
[
S { -- id: 0 -- income: $0.00 }; S { -- id: 1 -- income: $9.00 };
S { -- id: 2 -- income: $5.20 }
]
```
```catala-test-inline
@ -47,9 +50,13 @@ $ catala Interpret -s B
$ catala Interpret_Lcalc -s A --avoid_exceptions --optimize
[RESULT] Computation successful! Results:
[RESULT]
x = ESome [ESome S { -- id: ESome 0 -- income: ESome $0.00 };
ESome S { -- id: ESome 1 -- income: ESome $9.00 };
ESome S { -- id: ESome 2 -- income: ESome $5.20 }]
x =
ESome
[
ESome S { -- id: ESome 0 -- income: ESome $0.00 };
ESome S { -- id: ESome 1 -- income: ESome $9.00 };
ESome S { -- id: ESome 2 -- income: ESome $5.20 }
]
```
```catala-test-inline
$ catala Interpret_Lcalc -s B --avoid_exceptions --optimize

View File

@ -22,6 +22,10 @@ $ catala Interpret_Lcalc -s A --avoid_exceptions --optimize
[RESULT]
x = ESome [ESome 0; ESome 1; ESome 2; ESome 3; ESome 4; ESome 5; ESome 6]
[RESULT]
y = ESome [ESome 0; ESome 1; ESome 2; ESome 3; ESome 4; ESome 5; ESome 6;
ESome 7; ESome 8; ESome 9; ESome 10]
y =
ESome
[
ESome 0; ESome 1; ESome 2; ESome 3; ESome 4; ESome 5; ESome 6;
ESome 7; ESome 8; ESome 9; ESome 10
]
```

View File

@ -33,8 +33,11 @@ scope B:
$ catala Interpret -s A
[RESULT] Computation successful! Results:
[RESULT]
x = [S { -- id: 0 -- income: $0.00 }; S { -- id: 1 -- income: $9.00 };
S { -- id: 2 -- income: $5.20 }]
x =
[
S { -- id: 0 -- income: $0.00 }; S { -- id: 1 -- income: $9.00 };
S { -- id: 2 -- income: $5.20 }
]
```
```catala-test-inline
@ -47,9 +50,13 @@ $ catala Interpret -s B
$ catala Interpret_Lcalc -s A --avoid_exceptions --optimize
[RESULT] Computation successful! Results:
[RESULT]
x = ESome [ESome S { -- id: ESome 0 -- income: ESome $0.00 };
ESome S { -- id: ESome 1 -- income: ESome $9.00 };
ESome S { -- id: ESome 2 -- income: ESome $5.20 }]
x =
ESome
[
ESome S { -- id: ESome 0 -- income: ESome $0.00 };
ESome S { -- id: ESome 1 -- income: ESome $9.00 };
ESome S { -- id: ESome 2 -- income: ESome $5.20 }
]
```
```catala-test-inline
$ catala Interpret_Lcalc -s B --avoid_exceptions --optimize

View File

@ -29,7 +29,8 @@ $ catala Interpret_Lcalc -s A --avoid_exceptions --optimize
[RESULT] Computation successful! Results:
[RESULT]
a =
ESome 0.000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,078,695,580,959,228,473,468…
ESome
0.000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,078,695,580,959,228,473,468…
[RESULT] x = ESome 84.648,665,652,656,896,23
[RESULT] y = ESome -4.368,297,787,053,206,549,8
[RESULT] z = ESome 654,265,429,805,103,220,650,980,650.5…

View File

@ -55,10 +55,11 @@ $ catala Interpret_Lcalc -s S --avoid_exceptions --optimize
[RESULT] Computation successful! Results:
[RESULT]
a =
ESome A {
-- x: ESome -2.0
-- y: ESome B { -- y: ESome false -- z: ESome -1.0 }
}
ESome
A {
-- x: ESome -2.0
-- y: ESome B { -- y: ESome false -- z: ESome -1.0 }
}
[RESULT] b = ESome B { -- y: ESome true -- z: ESome 42.0 }
```
```catala-test-inline

View File

@ -29,9 +29,7 @@ $ catala Interpret_Lcalc -s S --avoid_exceptions --optimize
[RESULT] Computation successful! Results:
[RESULT]
a =
ESome A {
-- x: ESome 0
-- y: ESome B { -- y: ESome true -- z: ESome 0.0 }
}
ESome
A { -- x: ESome 0 -- y: ESome B { -- y: ESome true -- z: ESome 0.0 } }
[RESULT] b = ESome B { -- y: ESome true -- z: ESome 0.0 }
```

View File

@ -53,10 +53,11 @@ $ catala Interpret_Lcalc -s A --avoid_exceptions --optimize
[RESULT] Computation successful! Results:
[RESULT]
t =
ESome T {
-- a: ESome S { -- x: ESome 0 -- y: ESome false }
-- b: ESome S { -- x: ESome 1 -- y: ESome true }
}
ESome
T {
-- a: ESome S { -- x: ESome 0 -- y: ESome false }
-- b: ESome S { -- x: ESome 1 -- y: ESome true }
}
```
```catala-test-inline
$ catala Interpret_Lcalc -s B --avoid_exceptions --optimize
@ -64,8 +65,9 @@ $ catala Interpret_Lcalc -s B --avoid_exceptions --optimize
[RESULT] out = ESome 1
[RESULT]
t =
ESome T {
-- a: ESome S { -- x: ESome 0 -- y: ESome false }
-- b: ESome S { -- x: ESome 1 -- y: ESome true }
}
ESome
T {
-- a: ESome S { -- x: ESome 0 -- y: ESome false }
-- b: ESome S { -- x: ESome 1 -- y: ESome true }
}
```