Skip to content

Commit

Permalink
Message formatting: final touches
Browse files Browse the repository at this point in the history
  • Loading branch information
AltGr committed May 3, 2024
1 parent da89411 commit 56b456d
Show file tree
Hide file tree
Showing 92 changed files with 27 additions and 140 deletions.
1 change: 1 addition & 0 deletions compiler/catala_utils/message.ml
Original file line number Diff line number Diff line change
Expand Up @@ -394,5 +394,6 @@ let make
let debug = make ~level:Debug ~cont:emit
let log = make ~level:Log ~cont:emit
let result = make ~level:Result ~cont:emit
let results r = emit (List.flatten (List.map of_result r)) Result
let warning = make ~level:Warning ~cont:emit
let error = make ~level:Error ~cont:(fun m _ -> raise (CompilerError m))
1 change: 1 addition & 0 deletions compiler/catala_utils/message.mli
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ val debug : ('a, unit) emitter
val result : ('a, unit) emitter
val warning : ('a, unit) emitter
val error : ('a, 'b) emitter
val results : Content.message list -> unit
2 changes: 1 addition & 1 deletion compiler/catala_utils/pos.ml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ let format_loc_text_parts (pos : t) =
None )
else
let pr_head ppf =
Format.fprintf ppf "@{<blue>─➤ %s:@}@," (to_string_short pos)
Format.fprintf ppf "@{<blue>─➤ @{<bold>%s:@}@}@," (to_string_short pos)
in
let pr_context, pr_legal =
try
Expand Down
2 changes: 1 addition & 1 deletion compiler/desugared/print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ let print_exceptions_graph
Ast.ScopeDef.format var ScopeName.format scope;
Dependency.ExceptionsDependencies.iter_vertex
(fun ex ->
Message.result "@[<v>Definitions with label \"%a\":@]" LabelName.format
Message.result "Definitions with label@ \"%a\":" LabelName.format
ex.Dependency.ExceptionVertex.label
~extra_pos:
(List.map
Expand Down
6 changes: 3 additions & 3 deletions compiler/driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,9 @@ module Commands = struct
let language =
Cli.file_lang (Global.input_src_file options.Global.input_src)
in
Message.result "Computation successful!%s"
(if List.length results > 0 then " Results:" else "")
~outcome:
if results = [] then Message.result "Computation successful!"
else
Message.results
(List.map
(fun ((var, _), result) ppf ->
Format.fprintf ppf "@[<hov 2>%s@ =@ %a@]" var
Expand Down
1 change: 0 additions & 1 deletion tests/arithmetic/good/priorities.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│w = 0
│x = 4
│y = 4
Expand Down
1 change: 0 additions & 1 deletion tests/arithmetic/good/rounding.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ scope A:
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│o = false
└─
```
1 change: 0 additions & 1 deletion tests/arithmetic/good/trivial.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│w = 6
└─
```
2 changes: 0 additions & 2 deletions tests/array/good/aggregation.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,13 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = [$0.00; $9.00; $5.20]
└─
```

```catala-test-inline
$ catala test-scope B
┌─[RESULT]─
│Computation successful! Results:
│max = $18.00
│min = $5.00
│y = $17.20
Expand Down
2 changes: 0 additions & 2 deletions tests/array/good/aggregation_2.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x =
│ [
│ S { -- id: 0 -- income: $0.00 }; S { -- id: 1 -- income: $9.00 };
Expand All @@ -56,7 +55,6 @@ $ catala test-scope A
```catala-test-inline
$ catala test-scope B
┌─[RESULT]─
│Computation successful! Results:
│argmax = S { -- id: 1 -- income: $9.00 }
│argmin = S { -- id: 0 -- income: $0.00 }
└─
Expand Down
1 change: 0 additions & 1 deletion tests/array/good/aggregation_3.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ let scope S (x: integer|internal|output) =
```catala-test-inline
$ catala test-scope S
┌─[RESULT]─
│Computation successful! Results:
│x = 0
└─
```
1 change: 0 additions & 1 deletion tests/array/good/concatenation.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = [0; 1; 2; 3; 4; 5; 6]
│y = [0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10]
└─
Expand Down
2 changes: 0 additions & 2 deletions tests/array/good/filter.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = [$0.00; $9.00; $5.20]
└─
```

```catala-test-inline
$ catala test-scope B
┌─[RESULT]─
│Computation successful! Results:
│y = [$9.00; $5.20]
└─
```
2 changes: 0 additions & 2 deletions tests/array/good/filter_map.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = [$0.00; $9.00; $5.20]
└─
```

```catala-test-inline
$ catala test-scope B
┌─[RESULT]─
│Computation successful! Results:
│y = [$9.00; $5.20]
│z = [false; true; true]
└─
Expand Down
2 changes: 0 additions & 2 deletions tests/array/good/fold.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x =
│ [
│ S { -- id: 0 -- income: $0.00 }; S { -- id: 1 -- income: $9.00 };
Expand All @@ -56,7 +55,6 @@ $ catala test-scope A
```catala-test-inline
$ catala test-scope B
┌─[RESULT]─
│Computation successful! Results:
│argmax = S { -- id: 1 -- income: $9.00 }
│argmin = S { -- id: 0 -- income: $0.00 }
└─
Expand Down
1 change: 0 additions & 1 deletion tests/array/good/map.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope B
┌─[RESULT]─
│Computation successful! Results:
│x = [$4.00; $8.00]
│z = [false; true]
└─
Expand Down
2 changes: 0 additions & 2 deletions tests/array/good/simple.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = [0; 9; 64]
└─
```

```catala-test-inline
$ catala test-scope B
┌─[RESULT]─
│Computation successful! Results:
│v = 3
│w = true
│y = true
Expand Down
1 change: 0 additions & 1 deletion tests/array/good/simpler.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│w = false
│x = [0; 9; 64]
└─
Expand Down
1 change: 0 additions & 1 deletion tests/array/good/simplest.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = [0; 4; 8]
└─
```
1 change: 0 additions & 1 deletion tests/bool/good/test_bool.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ TestBool
```catala-test-inline
$ catala test-scope TestBool
┌─[RESULT]─
│Computation successful! Results:
│bar = 1
│foo = true
└─
Expand Down
1 change: 0 additions & 1 deletion tests/bool/good/test_precedence.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope TestBool
┌─[RESULT]─
│Computation successful! Results:
│foo = true
└─
```
1 change: 0 additions & 1 deletion tests/bool/good/test_xor.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope TestXor
┌─[RESULT]─
│Computation successful! Results:
│f_xor_f = false
│f_xor_t = true
│t_xor_f = true
Expand Down
1 change: 0 additions & 1 deletion tests/date/good/durations.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│m = [11874 days]
│m2 = [6 months]
│x = 2019-01-01
Expand Down
1 change: 0 additions & 1 deletion tests/date/good/rounding_option_en.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope Test
┌─[RESULT]─
│Computation successful! Results:
│r = true
└─
```
1 change: 0 additions & 1 deletion tests/date/good/rounding_option_fr.catala_fr
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope Test
┌─[RESULT]─
│Computation successful! Results:
│r = vrai
└─
```
1 change: 0 additions & 1 deletion tests/date/good/simple.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = 2019-01-01
│y = 2002-09-30
│z = [5937 days]
Expand Down
1 change: 0 additions & 1 deletion tests/dec/good/infinite_precision.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│a =
│ -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…
│x = 84.648,665,652,656,896,23
Expand Down
1 change: 0 additions & 1 deletion tests/dec/good/rounding.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = 84.648,665
│x1 = 85.0
│y = 4.368,297
Expand Down
1 change: 0 additions & 1 deletion tests/dec/good/simple.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│k = 0.333,333,333,333,333,333,33…
│x = 84.648,665
│y = 4.368,297
Expand Down
1 change: 0 additions & 1 deletion tests/dec/good/zero_after_comma.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = 4.0
│y = 1.04
└─
Expand Down
1 change: 0 additions & 1 deletion tests/default/good/mutliple_definitions.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ $ catala test-scope A
│ │ ‾‾‾‾‾‾‾‾‾‾‾‾
└─
┌─[RESULT]─
│Computation successful! Results:
│w = 3
└─
```
1 change: 0 additions & 1 deletion tests/enum/bad/useless_wildcard.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ $ catala test-scope A
│ │ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
└─ Useless wildcard
┌─[RESULT]─
│Computation successful! Results:
│x = Case1 ()
│y = 42
└─
Expand Down
1 change: 0 additions & 1 deletion tests/enum/good/disambiguated_cases.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│e = Case1 ()
│f = Case1 2
│x = 2
Expand Down
1 change: 0 additions & 1 deletion tests/enum/good/quick_pattern_check.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = Case1 2
│y = true
│z = false
Expand Down
1 change: 0 additions & 1 deletion tests/enum/good/simple.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = Case1 2
│y = 42
└─
Expand Down
2 changes: 0 additions & 2 deletions tests/enum/good/wildcard.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope Simple_case_2
┌─[RESULT]─
│Computation successful! Results:
│x = Case3 ()
│y = 31
└─
Expand All @@ -60,7 +59,6 @@ $ catala test-scope Simple_case_2
```catala-test-inline
$ catala test-scope Simple_case
┌─[RESULT]─
│Computation successful! Results:
│x = Case1 2
│y = 31
└─
Expand Down
1 change: 0 additions & 1 deletion tests/exception/good/duplicate_labels.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = 0
│y = 0
└─
Expand Down
1 change: 0 additions & 1 deletion tests/exception/good/exception.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = 1
└─
```
1 change: 0 additions & 1 deletion tests/exception/good/exceptions_squared.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = 2
└─
```
1 change: 0 additions & 1 deletion tests/exception/good/grouped_exceptions.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope Benefit
┌─[RESULT]─
│Computation successful! Results:
│benefit = $2,000.00
│person = Person { -- age: 26 -- disabled: true }
└─
Expand Down
1 change: 0 additions & 1 deletion tests/exception/good/groups_of_exceptions.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope Test
┌─[RESULT]─
│Computation successful! Results:
│x = 2
└─
```
Expand Down
1 change: 0 additions & 1 deletion tests/exception/good/same_label_two_variables.catala_en
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ $ catala Typecheck --check-invariants
```catala-test-inline
$ catala test-scope A
┌─[RESULT]─
│Computation successful! Results:
│x = 0
│y = 1
│z = 0
Expand Down
Loading

0 comments on commit 56b456d

Please sign in to comment.