Commit Graph

313 Commits

Author SHA1 Message Date
Denis Merigoux
a29339ed2f
Stringify JSON fields 2023-04-04 15:44:00 +02:00
Denis Merigoux
7d278caa30
Update OCaml assets 2023-04-04 15:19:08 +02:00
Denis Merigoux
b3949ae15c
Update assets 2023-03-31 16:55:51 +02:00
Denis Merigoux
5673708f36
Update assets 2023-03-31 15:34:51 +02:00
Louis Gesbert
a415355a39 Rework the AST Gadt to allow merging of different ASTs
The phantom polymorphic variant qualifying AST nodes is reversed:
- previously, we were explicitely restricting each AST node to the passes where it belonged using a closed type (e.g. `[< dcalc | lcalc]`)
- now, each node instead declares the "feature" it provides using an open type (e.g. `[> 'Exceptions ]`)
- then the AST for a specific pass limits the features it allows with a closed type

The result is that you can mix and match all features if you wish,
even if the result is not a valid AST for any given pass. More
interestingly, it's now easier to write a function that works on
different ASTs at once (it's the inferred default if you don't write a
type restriction).

The opportunity was also taken to simplify the encoding of the
operators, which don't need a second type parameter anymore.
2023-03-30 15:30:08 +02:00
Denis Merigoux
f3e4127bcc
Update assets 2023-03-30 15:09:45 +02:00
Denis Merigoux
3417d07945
Fixed bug in L861-5-1 2023-03-28 12:09:52 +02:00
Denis Merigoux
3122dd7821
Update assets 2023-03-21 16:10:00 +01:00
Denis Merigoux
48ef5b8f21
Fix warning and update assets 2023-03-21 14:00:49 +01:00
Denis Merigoux
5d3aded38d
Update Python API 2023-03-20 11:18:55 +01:00
Denis Merigoux
79d6c0e25d
Fix ML and JS french law 2023-03-17 18:59:41 +01:00
Denis Merigoux
7f705beb07
Merge branch 'master' into aides_logement_outre_mer 2023-03-17 17:52:10 +01:00
Denis Merigoux
4fcdd005e0
Merge branch 'master' into aides_logement_outre_mer 2023-03-17 09:18:27 +01:00
Raphaël Monat
a09b4b82fd Updating french_law 2023-03-16 17:20:13 +01:00
Raphaël Monat
64fa32392f Update generated files 2023-03-16 17:20:09 +01:00
Raphaël Monat
7021c41f93 Add date rounding option within scopes 2023-03-16 16:55:55 +01:00
Denis Merigoux
74df4ee988
Merge branch 'master' into aides_logement_outre_mer 2023-03-14 14:10:09 +01:00
Denis Merigoux
283d82bfce
French law JS must be created with a dune release profile 2023-03-14 11:53:27 +01:00
Louis Gesbert
508992de33 Embed the Pygments Catala lexer
This enables the HTML output to work without a custom Pygments installation (or
the proper venv activated)
2023-03-13 14:41:24 +01:00
Louis Gesbert
deb12d2c4a Bump version to 0.8.0
Changelog:
---

A lot has been going on, with more than 530 patches and 70 PRs merged since
0.7.0 last summer. In summary:

- Quite a lot of syntax improvements and changes. Checkout the latest
  [cheat-sheet](https://catalalang.github.io/catala/syntax.pdf) for an overview

- Allow local `let ... equals ... in ...` definitions

- Better error messages and positions throughout

- Added the ability to directly call a scope and retrieve its outputs, like a
  function

- Added disambiguation, allowing to access structure fields without specifying
  the structure type each time

- Added automated resolution of operators, allowing e.g. to write just `+` in
  place of all the type-specific operators `+.`, `+$`, `+@`, `+^`, etc.

- More consistent priority for operators. It is no longer allowed to write `a
  and b or c` without parenthesis.

- Added and changed some operators (`date + duration` now allowed either way,
  `int / int` now returns a decimal, added `duration / duration`)

- Added the ability to have variables and functions defined at
  top-level (outside of any scope). See annex A of the tutorial for details.

- Added support for functions with multiple arguments

- Some big refactors in the compiler, allowing much better code sharing between
  the different passes, and making it much easier to extend. Also added the
  possibility to run the type-checker earlier, etc.

- Countless bug-fixes

- Improvements to our proof backend with Z3

- A tool to automatically synchronise with the upstream French law from
  Legifrance
2023-03-08 18:07:53 +01:00
Denis Merigoux
bfc827296c
Merge branch 'master' into aides_logement_outre_mer 2023-03-06 14:09:51 +01:00
adelaett
c680b932ff update nix files 2023-03-03 14:51:51 +01:00
Denis Merigoux
74175907ca
Adelaett fix arrowlist (#409) 2023-03-03 14:04:04 +01:00
Louis Gesbert
a3b9045745 Update the cheat-sheet
- Add the new syntax for multi-argument functions
- Add the syntax for defining top-level values
- Increased font size and improved compacity
2023-03-02 17:00:14 +01:00
Louis Gesbert
cf2e80ba51 Refactor Python dependency handling
* Use the newer "pyproject.toml" for syntax highlighters
* Use venv for everything (previously, the pygment lexers were installed
  globally, but more recent Python releases frown upon that. This will probably
  be more stable in the long run...)
* Use one venv at the root of the project (`_python_venv/`) for both
  pygments and the runtime
* Initialise this venv automatically from the Makefile (it should no longer be
  necessary to run scattered `set_up.sh` scripts with mysterious interactions)

On the downsides, though:
* Only tested with Python 3.11 at the moment
* Need to remember to activate the venv (`. _python_venv/bin/activate`) from the
  root for e.g. HTML literate output to work. A more manageable solution could
  be for Catala to provide the lexers on-the-fly when calling `pygmentize`.
2023-03-02 16:24:53 +01:00
adelaett
290e67ea7e adding the parsing code to the CI. 2023-02-28 15:23:19 +01:00
Denis Merigoux
0667e3d40f
Merge branch 'master' into aides_logement_outre_mer 2023-02-28 15:01:31 +01:00
Louis Gesbert
72cf477dd9 Toplevel definitions: fixes following review
Thanks @denismerigoux!
2023-02-15 12:40:15 +01:00
Louis Gesbert
c3af0b4097 Toplevel definitions: branch cleanup
- fix remaining warnings (mostly unused arguments)
- renamings throughout for consistency and clarity
2023-02-13 18:02:09 +01:00
Louis Gesbert
912e1500c4 Handle toplevel defs down to scalc 2023-02-13 11:44:32 +01:00
Louis Gesbert
9b0c7583ec Add top-level definitions
Only handled until before scalc at the moment.
2023-02-13 11:43:49 +01:00
Louis Gesbert
0540cd31fe Allow ETuple, ETupleAccess on all ASTs
they used to be only allowed on lcalc
2023-02-13 10:51:42 +01:00
Denis Merigoux
c24d61a3aa
Update assets and APIs with residence 2023-02-08 13:53:19 +01:00
Louis Gesbert
352bb89b53 Catala-legifrance: fix error handling 2023-02-01 11:20:19 +01:00
Louis Gesbert
07870eb2f6 Legifrance API: better use of LWT, and retry token query 2023-01-26 18:10:25 +01:00
Louis Gesbert
ca7f14e219 formatting fix 2023-01-16 12:10:33 +01:00
Louis Gesbert
f835225a34 Tiny parser simplification
There is no need to keep separate rules for the different kinds of binops anymore.
2023-01-16 12:09:19 +01:00
Denis Merigoux
d86eb8cb03
Ajout revalorisation plafond ASPA 2023 2023-01-10 11:47:14 +01:00
Denis Merigoux
843ae5465b
Merge branch 'master' into aides_logement 2023-01-07 21:01:19 +01:00
Denis Merigoux
bed7617581
Update smic 2023-01-07 20:53:05 +01:00
Denis Merigoux
b3057e1d7c
Continue cleaning 2023-01-07 20:42:42 +01:00
Denis Merigoux
050c7c46de
Update assets 2023-01-07 20:28:41 +01:00
Denis Merigoux
90be4dbd0e
Improving bench 2023-01-06 17:08:12 +01:00
Denis Merigoux
a3fffb3c8d
Forgot log 2023-01-05 16:43:53 +01:00
Denis Merigoux
d049f998ac
Update assets 2023-01-05 16:32:51 +01:00
Denis Merigoux
fd12549949
Updating assets 2023-01-05 16:21:10 +01:00
Denis Merigoux
fa84dd4330
Splitting long lines 2023-01-05 16:20:51 +01:00
Denis Merigoux
76d5e44685
More man pages 2023-01-04 17:34:09 +01:00
Denis Merigoux
d2ce111fc2
Better legifrance inclusion 2023-01-04 16:30:14 +01:00
Louis Gesbert
2003566867 Force parens in compound logic formulas
Closes #373

This forbids expressions such as `a and b or c`, avoiding the need to set an
implicit priority between `and`, `or` and `xor`, which I find error-prone.

Instead, when that appears, a message asking for explicit parentheses will be
shown to the user.

Implementation note: since that would be extremely tedious to do in the parser
directly, the parser is set to allow right-associativity without discrimination
for the logical operators, and the check is done during desugaring. This
required to explicit parentheses in the surface AST to discriminate the case
where the priority was explicit.
2023-01-04 10:46:14 +01:00
Louis Gesbert
51df581aba Small cleanup/fixes following PR review on Syntax Changes 2022-12-20 16:03:41 +01:00
Louis Gesbert
9e514755b7 Collection syntax: re-add combined filter+map 2022-12-19 15:17:17 +01:00
Louis Gesbert
f236e2cfb2 Replace the type conversion and rounding operators with overloads
Ref. #366

Also updates `CONTRIBUTING.md`.

This was pretty straight-forward :)
2022-12-13 15:32:49 +01:00
Louis Gesbert
bb58d11ca8 Improve syntax for scope calls
implements #357
2022-12-13 12:30:38 +01:00
Louis Gesbert
71bb67163c Remove explicitely typed operators in tests and examples
Command used: `sed -i 's/\([-+*/><=]=\?\)[.$@^€$]/\1/g' **/*/*.catala_*`

The overload test, of course, is kept unchanged and ensures that explicit
operators still work.
2022-12-13 12:00:04 +01:00
Louis Gesbert
fea01cfe4c Add overloaded operators for the common operations
This uses the same disambiguation mechanism put in place for
structures, calling the typer on individual rules on the desugared AST
to propagate types, in order to resolve ambiguous operators like `+`
to their strongly typed counterparts (`+!`, `+.`, `+$`, `+@`, `+$`) in
the translation to scopelang.

The patch includes some normalisation of the definition of all the
operators, and classifies them based on their typing policy instead of
their arity. It also adds a little more flexibility:
- a couple new operators, like `-` on date and duration
- optional type annotation on some aggregation constructions

The `Shared_ast` lib is also lightly restructured, with the `Expr`
module split into `Type`, `Operator` and `Expr`.
2022-12-13 11:55:24 +01:00
Louis Gesbert
5bcc0a65eb Improve some messages on structure disambiguation 2022-12-13 11:47:21 +01:00
Louis Gesbert
4ee4a96ac7 Remove *all* struct field access qualifiers in catala code
They are no longer needed \o/
2022-11-28 16:42:02 +01:00
Louis Gesbert
8960e5dbbc Add typing-based disambiguation pass after desugaring
Some typing errors are changed a little, because they get triggered during the
typing of the disambiguation pass, which does not specify the expected return
type (it's an expected invariant that it should not be needed for
disambiguation).

It would be possible to still specify these types during disambiguation just to
get the same errors, but since the newer ones don't appear to be clearly worse
at the moment, it has not been done.
2022-11-28 16:38:09 +01:00
Louis Gesbert
af2f5dbe19 Tweak error message location printing 2022-11-28 16:38:09 +01:00
Louis Gesbert
660e5775de Rename utils to catala_utils 2022-11-28 16:38:09 +01:00
Denis Merigoux
d7b9396e87
Correct lines 2022-11-24 15:17:00 +01:00
Louis Gesbert
4ae392c900 AST refactoring
Many changes got bundled in here and would be too tedious to separate.

Closes #330

See changes in `shared_ast/definitions.ml` to check the main point.

- the biggest change is a modification of the struct and enum types in
  expressions: they are now stored as `Map`s throughout passes, and no longer
  converted to indexed lists after scopelang. Their accessors are also changed,
  and tuples only exist in Lcalc (they're used for closure conversion).

  This implied adding some more information in the contexts, to keep the mapping
  between struct fields and scope output variables. It should also be much more
  robust (no longer relying on assumptions upon different orderings).

- another very pervasive change is more cosmetic: the rewrite of the main AST to
  use inline records, labelling individual subfields.

- moved the checks for correct definitions and accesses of structures from
  `Scope_to_dcalc` to `Typing`

- defining some new shallow iterators in module `Shared_ast.Expr`, and
  factorising a few same-pass rewriting functions accordingly (closure
  conversion, optimisations, etc.)

- some smaller style improvements (ensuring we use the proper compare/equal
  functions instead of `=` in a few `when` closes, for example)
2022-11-17 18:16:09 +01:00
Louis Gesbert
a51d082033 Use scope calls in "Aides logement" 2022-11-07 14:23:10 +01:00
Louis Gesbert
43fc2a28b7 Fix french law examples for API changes
output structs/vars are no longer tagged `out`
2022-10-25 14:50:49 +02:00
Louis Gesbert
b19a7660fc Fix ambiguities in examples 2022-10-21 17:36:44 +02:00
Louis Gesbert
41d6d3cbe9 Make scopes directly callable
Quite a few changes are included here, some of which have some extra
implications visible in the language:

- adds the `Scope of { -- input_v: value; ... }` construct in the language

- handle it down the pipeline:
  * `ScopeCall` in the surface AST
  * `EScopeCall` in desugared and scopelang
  * expressions are now traversed to detect dependencies between scopes
  * transformed into a normal function call in dcalc

- defining a scope now implicitely defines a structure with the same name, with
  the output variables of the scope defined as fields. This allows us to type
  the return value from a scope call and access its fields easily.
  * the implications are mostly in surface/name_resolution.ml code-wise
  * the `Scope_out` struct that was defined in scope_to_dcalc is no longer
    needed/used and the fields are no longer renamed (changes some outputs; the
    explicit suffix for variables with multiple states is ignored as well)
  * one benefit is that disambiguation works just like for structures when there
    are conflicts on field names
  * however, it's now a conflict if a scope and a structure have the same
    name (side-note: issues with conflicting enum / struct names or scope
    variables / subscope names were silent and are now properly reported)

- you can consequently use scope names as types for variables as well. Writing
  literals is not allowed though, they can only be obtained by calling the
  scope.

Remaining TODOs:

- context variables are not handled properly at the moment

- error handling on invalid calls

- tests show a small error message regression; lots of examples will need
  tweaking to avoid scope/struct name or struct fields / output variable
  conflicts

- add a `->` syntax to make struct field access distinct from scope output var
  access, enforced with typing. This is expected to reduce confusion of users
  and add a little typing precision.

- document the new syntax & implications (tutorial, cheat-sheet)

- a consequence of the changes is that subscope variables also can now be typed.
  A possible future evolution / simplification would be to rewrite subscopes as
  explicit scope calls early in the pipeline. That could also allow to manipulate
  them as expressions (bind them in let-ins, return them...)
2022-10-21 17:17:26 +02:00
Denis Merigoux
f037a39bf4
Merge branch 'master' into aides_logement 2022-10-17 16:42:46 +02:00
Louis Gesbert
d93b699a4c Forward types in the Expr.make_* constructors
Also add some safeguards against bad propagation of types (e.g. checking the
arrow type of functions upon application); partly disabled at the moment since
they don't pass yet but that'll be further work.
2022-10-04 14:50:37 +02:00
Denis Merigoux
65f4635510
A new case 2022-09-28 16:03:14 +02:00
Denis Merigoux
6b24f7145d
Fix bug 2022-09-27 16:10:23 +02:00
Denis Merigoux
9cb7e86bfc
List to investigate 2022-09-26 19:28:07 +02:00
Denis Merigoux
0a9a593c61
Restore base input 2022-09-26 19:23:30 +02:00
Denis Merigoux
89dab52caa
Tweaks 2022-09-26 19:19:15 +02:00
Denis Merigoux
e6ba0980d8
CNAF->Catala input conversion (injection but not surjection) 2022-09-26 19:01:29 +02:00
Denis Merigoux
a805ac0acc
Minor tweaks 2022-09-26 17:35:43 +02:00
Denis Merigoux
0beaf6eb31
Comparing with Catala! 2022-09-26 17:29:05 +02:00
Denis Merigoux
0c0267055e
Update assets 2022-09-26 15:59:11 +02:00
Denis Merigoux
7ab74501b8
Playing mouse and cat with the CNAF form 2022-09-26 15:44:38 +02:00
Denis Merigoux
309dfb6c3e
Random input generator 2022-09-26 15:44:30 +02:00
Denis Merigoux
2460dffe3f
Starting random input generator 2022-09-26 13:28:07 +02:00
Denis Merigoux
8dd45788a6
Automation of the CNAF's site working 2022-09-26 13:28:07 +02:00
Denis Merigoux
4df71d8bae
Beginning to port https://github.com/jboillot/apl-fetcher 2022-09-26 13:28:07 +02:00
Denis Merigoux
365037f70c
Correctly bench 2022-09-26 13:28:07 +02:00
Denis Merigoux
463b0965e3
Same example in Puython and in JS 2022-09-26 13:28:07 +02:00
Denis Merigoux
3f62a99b7a
Remove erroneous import 2022-09-26 13:28:07 +02:00
Denis Merigoux
32c89cc3a2
Fix Python backend for housing benefits 2022-09-26 13:28:07 +02:00
Denis Merigoux
89b625642f
Money from int and not from float 2022-09-26 13:28:06 +02:00
Denis Merigoux
431a0b99c1
Initial writeup of Python calling to housing benefits 2022-09-26 13:28:06 +02:00
Denis Merigoux
6e64f769a0
Update assets and rename executable 2022-09-08 15:16:39 +02:00
Denis Merigoux
1df20c18ac
Fixing discrepancies with LegiFrance in French housing benefits 2022-09-08 12:30:16 +02:00
Denis Merigoux
dba9b40ff6
Restore diff checking 2022-09-07 17:51:41 +02:00
Denis Merigoux
3accabe03a
Update assets 2022-09-07 17:26:40 +02:00
Denis Merigoux
8445174a5b
Improvements to expiration checking 2022-09-07 17:14:22 +02:00
Denis Merigoux
0670dd697f
Correct expiration checking 2022-09-07 13:03:12 +02:00
Denis Merigoux
09fc71c625
Differenciating API requests depending on text ID (beginning) 2022-09-06 18:32:26 +02:00
Denis Merigoux
19ba5ce923
Don't process everything at the same time 2022-09-06 18:00:22 +02:00
Denis Merigoux
1990b0b970
Code compiles 2022-09-06 17:25:57 +02:00
Denis Merigoux
2ffafdbd3a
Bring back files from ancient git history 2022-09-06 15:56:36 +02:00
Denis Merigoux
0e3616d8ef
Update assets 2022-09-06 14:27:56 +02:00