Commit Graph

1405 Commits

Author SHA1 Message Date
Louis Gesbert
12974b089f Printer: skip unit variables for conciseness 2024-02-07 17:54:12 +01:00
Louis Gesbert
a56d95d790 Typing: add a "assume operator types" mode
This allows for retyping after monomorphisation: a new function just extracts
the return type of the operator, without checking the operand types.

Also to avoid multiplying function arguments around the typer, the flags have
been gathered in a record that is included in the typing environment; it's ok to
give them default values as long as these are the strictest.
2024-02-07 17:41:04 +01:00
Louis Gesbert
ea512bfd5b The typer doesn't handle monomorphised code yet
so don't retype after monomorphisation, which is now possible as the pass itself
correctly preserves types.

In time the typer will need a special case to get knowledge of the new types and
modified operator types.
2024-02-06 18:00:45 +01:00
Louis Gesbert
df70c5dd57 Simplify monomorphisation, and preserve type annotations 2024-02-06 18:00:25 +01:00
Louis Gesbert
e5fe02fd84 Interpreter: avoid rebuilding unchanged values
Closes #540 ; it was a leftover from when we were still exploring how best to
type this function.
2024-02-05 16:28:56 +01:00
Louis Gesbert
7f5b56e8f2 Interpreter: remove no longer needed empty propagations 2024-02-05 16:28:56 +01:00
Louis Gesbert
870716a3f8 Factorise a bit more with more arguments to Expr.map
allowing a safer way to translate types both in expressions and annotations, and
clarifying the code of the dcalc->lcalc translation
2024-02-05 16:28:56 +01:00
Louis Gesbert
61c105c365 Add one more trivial optimisation 2024-02-05 11:01:55 +01:00
Louis Gesbert
5cb8ba805b List detuplification: better intermediate vars namings
for more readable code
2024-02-05 11:01:55 +01:00
Louis Gesbert
7b43f393c5 Add some optimisations to nested maps 2024-02-05 11:01:55 +01:00
Denis Merigoux
afa8ee44bf
Delete duplicate code from 9d3550374d 2024-02-01 17:23:31 +01:00
Denis Merigoux
d7e71885c1
Formatting 2024-02-01 17:22:42 +01:00
Louis Gesbert
f90de90299 Monomorphisation: access types directly 2024-02-01 12:27:54 +01:00
Louis Gesbert
2dba54b906 Monomorphisation: simplify type collection 2024-02-01 12:22:31 +01:00
Louis Gesbert
9d3550374d Remove constructor matching on strings 2024-02-01 12:17:51 +01:00
Louis Gesbert
cfdaf94989 Define Type.Map 2024-02-01 10:10:25 +01:00
Louis Gesbert
e47a1fc220 Improve translation of typing upon dcalc -> lcalc
A little bit of effort enables us to propagate valid typing annotations, making
subsequent typing re-inference easier (and avoiding a traversal just to remove
type annotations)
2024-01-31 19:15:27 +01:00
Louis Gesbert
7a4ac4364b Mark closure conversion as untyped
since it doesn't correctly propagate and update types. (Ideally it would, but
otherwise it would be better to remove the type annotations on the fly instead
of introducing wrong ones then cleaning them up).
2024-01-31 17:52:06 +01:00
Louis Gesbert
e8e112d7f7 Add tuples to the Python backend 2024-01-31 11:02:03 +01:00
Louis Gesbert
5d233f4532 Fix warning 2024-01-29 11:37:42 +01:00
Denis Merigoux
a033f02689
Restore tests 2024-01-29 11:06:48 +01:00
Denis Merigoux
b48fb0e223
Array compilation to C is OK 2024-01-26 20:15:32 +01:00
Denis Merigoux
3e807ae071
Remove warnings 2024-01-26 17:53:49 +01:00
Denis Merigoux
a39b67bf12
Merge branch 'master' into c_backend 2024-01-26 17:43:07 +01:00
Louis Gesbert
371f9554b8 Support for list recombinations
The primary use-case for this was to be able to run computations on a list of
structures, then return an updated list with some fields in the structures
modified : that is what we need for distribution of tax amounts among household
members, for example.

This patch has a few components:

- Addition of a test as an example for tax distributions

- Added a transformation, performed during desugaring, that -- where lists are
  syntactically expected, i.e. after the `among` keyword -- turns a (syntactic)
  tuple of lists into a list of tuples ("zipping" the lists)

- Arg-extremum transformation was also fixed to use an intermediate list instead
  of computing the predicate twice

- For convenience, allow to bind multiple variables in most* list
  operations (previously only `let in` and functions allowed it)

- Fixed the printer for tuples to differentiate them from lists

*Note: tuples are not yet allowed on the left-hand side of filters and
arg-extremums for annoying syntax conflict reasons.
2024-01-26 11:29:33 +01:00
Louis Gesbert
bc90a7b890 Add (internally) a map2 operator 2024-01-26 11:22:12 +01:00
Louis Gesbert
a9f8fa36b8 Reduce default verbosity of invariant checks
they break the tests too often for no good reason
2024-01-25 18:18:43 +01:00
Louis Gesbert
7b25a42970 Better version handling
Always generate the version through git when possible, and encode that within
the binaries so that `catala --version` does'nt give misleading information.

Previously we used dune's builtin functionality, but that resorts to a hack at
install time which is unpleasant and doesn't work with our use of `opam
install`.

The cost is a re-linking of catala_utils and the binaries upon git commit, which
is hardly noticeable.
2024-01-24 11:41:34 +01:00
Denis Merigoux
34c62a73c1
Improve missing field error message 2024-01-23 12:05:18 +01:00
Denis Merigoux
8a139f6a3c
Work on arrays 2024-01-22 16:49:58 +01:00
Louis Gesbert
7636a6e8d5 CI: cleanup the exposed artifacts 2024-01-22 13:58:32 +01:00
Louis Gesbert
81eb7bf6d2 CI: Fix artifact source dir 2024-01-20 11:51:01 +01:00
Louis Gesbert
c336a7bb62
[WIP] Rehaul CI to run examples and generate artifacts again (#562) 2024-01-19 18:34:24 +01:00
Louis Gesbert
1c2c41b2ff Allow literal scope output structures 2024-01-19 15:43:35 +01:00
Louis Gesbert
c006c3343e Rehaul CI to run examples and generate artifacts again
this requires to fetch catala-examples and french-law from their own repos

Restrict static builds and publication to master
2024-01-18 16:14:27 +01:00
Louis Gesbert
d9a17db4c0 Fix running inline tests
Warning: one of them is broken and was disabled
2024-01-18 16:14:27 +01:00
Denis Merigoux
50d3164f36
Restore C compilation 2024-01-17 17:26:41 +01:00
Denis Merigoux
5310e47e5b
Fix monomorphization problems with [TAny] left 2024-01-17 16:03:20 +01:00
Denis Merigoux
0a8fdde7de
Fix monomorphization 2024-01-17 14:02:32 +01:00
Denis Merigoux
ca8e4989ea
Type Scalc flow to avoid unresolved typing
With the new EAppOp node, the typing of operator application has changed and this causes some problems
with the example in test_scope/good/nothing.catala_en when retyping the LCalc to go to Scalc. This
commit changes the weird thing that for generating Scalc, the "typed" parameter was set to "untyped".
2024-01-17 13:08:20 +01:00
Denis Merigoux
a1ab58478c
Remove useless field 2024-01-17 11:29:39 +01:00
Denis Merigoux
349da741d4
Merge branch 'master' into c_backend 2024-01-16 16:23:35 +01:00
Louis Gesbert
8ed45c2762
Fixes missing minus sign printing for small negative amounts of money (#560) 2024-01-16 12:21:29 +01:00
Denis Merigoux
15c7691c09
Fixes #555 2024-01-16 11:40:10 +01:00
Denis Merigoux
b616e60c79
Fixes #558 2024-01-16 11:29:45 +01:00
Denis Merigoux
9f03b6b931
Merge branch 'master' into c_backend
Some tests still failing...
2024-01-15 17:19:17 +01:00
Louis Gesbert
12f208b3fc Adding tuples: fixes following review 2024-01-08 12:16:07 +01:00
Denis Merigoux
919dd2b812 Monomorphization properly done 2023-12-20 17:45:39 +01:00
Denis Merigoux
dcd883e53c
Uppercase constructors 2023-12-19 17:40:38 +01:00
Denis Merigoux
a9764d607e
Merge branch 'master' into c_backend 2023-12-19 17:39:02 +01:00