Commit Graph

320 Commits

Author SHA1 Message Date
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
Denis Merigoux
6130151c8e
Fix bug and typos 2022-09-05 14:50:37 +02:00
Denis Merigoux
7db0174676
Letting go of webpack optimizations 2022-08-30 16:22:13 +02:00
Denis Merigoux
1c3d5b9a75
Fix all lines too long problems & update assets 2022-08-29 15:46:06 +02:00
Denis Merigoux
e5963e5381
Merge branch 'master' into altgr_allmarks 2022-08-29 11:57:06 +02:00
Denis Merigoux
e41e0f9dcc
Fix line length and display lines of code 2022-08-26 12:05:22 +02:00
Louis Gesbert
2b6ee8dd4b Leverage the shared AST: big cleanup (part I) 2022-08-22 19:28:21 +02:00
Denis Merigoux
062fea89d7
No RLS for logement-foyers 2022-08-19 11:54:15 +02:00
Denis Merigoux
d6ad4604ce
Only social conventions for logement-foyers 2022-08-19 11:39:04 +02:00
Denis Merigoux
1553f88cf5
Remove unnecessary input 2022-08-18 18:53:30 +02:00
Denis Merigoux
2bc1b7d7f7
RLS only for social housing 2022-08-18 16:00:52 +02:00
Denis Merigoux
62ff234319
Shuffle data around 2022-08-18 15:27:01 +02:00
Denis Merigoux
c36f6b683b
Don't minify as much with js_of_ocaml to workaround Webpack bug 2022-08-16 19:11:58 +02:00
Denis Merigoux
331789bfee
Remove input data duplicate 2022-08-16 17:39:18 +02:00
Denis Merigoux
caded9c6e2
End of lines 2022-08-16 17:02:36 +02:00
Denis Merigoux
82940b63e3
Remove mode_occupation from AL/APL logement-foyer's input
In favor of a more restricted input
2022-08-16 17:01:53 +02:00
Denis Merigoux
92189e6439
Fix bug introduced by a1ebb67 2022-08-16 14:40:12 +02:00
Denis Merigoux
a1ebb6715c
Remove age prompts, deduct from birth date correctly 2022-08-16 11:08:13 +02:00
Denis Merigoux
4336fb0a41
Update assets 2022-08-15 18:38:15 +02:00
Denis Merigoux
93f6a19ea9
Update assets 2022-08-15 18:01:12 +02:00
Denis Merigoux
c278f61cf2
Update assets 2022-08-15 17:21:43 +02:00
Denis Merigoux
c71b8e28c6
Moving parameters into property-section of data 2022-08-12 11:16:52 +02:00
Denis Merigoux
1af33ef8b2
Update assets 2022-08-11 18:24:04 +02:00
Denis Merigoux
7b7d31d0a5
Fix non-negative value bug in housing benefits 2022-08-11 16:16:00 +02:00
Denis Merigoux
a48e90150c
Use let-bindings to refactor code 2022-08-11 14:12:11 +02:00
Denis Merigoux
038e6068e6
Small improvements to housing benefits 2022-08-10 18:13:07 +02:00
Denis Merigoux
8696490265
Fixes #307 2022-08-09 14:39:43 +02:00
Denis Merigoux
0351d90087
Update assets 2022-08-08 17:25:49 +02:00
Emile Rolley
f30dc376fd doc(compiler): add information about the html generation logic + complete the doc of the Utils module 2022-08-05 19:03:59 +02:00
Emile Rolley
70672088fa nitpick: String_common.is_uppercase renamed in String_common.is_uppercase_ascii 2022-08-05 18:18:06 +02:00
Emile Rolley
5534145737 french_law: update the JS lib 2022-08-05 11:20:32 +02:00
Louis Gesbert
a569589193 Small improvements to the Python and OCaml pretty-printers 2022-08-04 20:43:39 +02:00
Louis Gesbert
922126b5cd Improve api_web pretty-printer 2022-08-04 17:36:50 +02:00
Louis Gesbert
e50b567000 Fix relative dir in french_law artifacts ; add a note in examples/README.md 2022-08-04 17:36:50 +02:00
Louis Gesbert
289975ebe8 Generate french law python artifacts through dune
(they're no longer reformatted, at the moment, though)
2022-08-03 19:04:14 +02:00
Louis Gesbert
c964495c59 Generate website assets through dune 2022-08-03 19:04:13 +02:00
Louis Gesbert
1dbcc31599 Shell script tweaks 2022-08-03 19:03:27 +02:00
Louis Gesbert
9db038812c Include generation of json_schema artifacts
(plus other small Makefile improvements)
2022-08-03 18:55:42 +02:00
Louis Gesbert
0600501ec6 Generate french_law artifacts through dune
The files where manually generated through Makefile rules, and
versionned (with an outdated version).

The issue was that we had:
- `dune` building Catala
- Makefiles calling `catala` to build and copy the `french_law/ocaml/law_source`
  files
- then `dune` again to build `french_law`

The result was that `dune build` (without running `make` first) would
return a weird error.

The proposed solution adds ad-hoc dune rules to call the catala
binary, so that it can handle the whole pipeline correctly. If OCaml
is purely a backend, though, a simpler solution that makes us less
dependent on dune would be to handle the compilation of `french_law`
manually.

The dune rules are set to 'promote' the files so that it preserves the
fact that they are versionned (but with no confusion of the build system
about where they should come from anymore)
2022-08-03 18:55:42 +02:00
Emile Rolley
1a6934b538 feat(build): add the generation of json schemas to the build workflow 2022-07-29 18:47:42 +02:00
Emile Rolley
26663f227d fix(plugins/web): fix enum payload + retrieve all required types 2022-07-29 18:42:47 +02:00
Emile Rolley
8e3fd34424 refactor(plugins/jsoo): encode Catala date in JS string object instead of date 2022-07-29 18:42:41 +02:00
Denis Merigoux
5a74f7bd0b Fix all errors 2022-07-29 18:42:14 +02:00
Denis Merigoux
4845196b5b Add source positions in all backends exceptions 2022-07-29 18:42:14 +02:00
Emile Rolley
6e825906de refactor(api_web): factorizes the api_web code + updates .gitattributes 2022-07-28 15:02:43 +02:00
Denis Merigoux
97b6e14740 Removed useless variable 2022-07-28 15:02:43 +02:00
Denis Merigoux
0c4682dc3f Graceful error catching 2022-07-28 15:02:43 +02:00
Denis Merigoux
fa36fb0df1 Housing benefits extract to Python and compute 2022-07-28 15:02:43 +02:00
Denis Merigoux
0f999fb285 Reflect change in filename 2022-07-28 15:02:43 +02:00
Denis Merigoux
d91ed27e28 The JS version of the housing benefits computation is working! 2022-07-28 15:02:43 +02:00
Emile Rolley
4f828c300e fix(jsoo): fix the translating of TUnit and TDuration to JSOO types 2022-07-28 15:02:43 +02:00
Denis Merigoux
7461a8db31 Generating OCaml for aides au logement 2022-07-28 15:02:43 +02:00
Denis Merigoux
fa55a83fb4
Merge branch 'master' into 290-jsoo-wrapper-plugin 2022-07-22 17:54:51 +02:00
Denis Merigoux
a73be79d61
Update assets 2022-07-22 17:14:58 +02:00
Emile Rolley
d9045499c0 refactor(french_law/ocaml): refactor the api_web.ml 2022-07-22 17:01:33 +02:00
Emile Rolley
231f327efb feat(jsoo): v1 jsoo plugin 2022-07-22 16:52:56 +02:00
Emile Rolley
15be4b7279 refactor(law_source): remove the unused Enfant submodule from the allocation_familiales.mli 2022-07-22 16:52:56 +02:00
Denis Merigoux
df9f02f943
Update Python asset 2022-07-22 16:29:47 +02:00
Denis Merigoux
0304602433 Trying to fix Bindlib unboxing bug [skip ci] 2022-07-22 12:31:05 +02:00
Emile Rolley
61899cd698 fix(examples): assets are now generated from the repo root 2022-07-20 18:29:01 +02:00
Denis Merigoux
bf33cbfa49
Updating assets 2022-07-20 15:58:24 +02:00
Louis Gesbert
19dbce895c Shell scripts: POSIX + correct error reporting 2022-07-20 12:04:30 +02:00
Emile Rolley
4991350b58 feat(backend/ocaml): disambiguate OCaml record names derived from Catala struct 2022-07-12 16:12:18 +02:00
Denis Merigoux
5e45940e1b
Merge branch 'master' into allocations_logement 2022-07-06 16:43:14 +02:00
Denis Merigoux
ea6083d5a2
Disable optimisations for french_law.js because of #274 2022-07-04 12:14:21 +02:00
Denis Merigoux
07b348a309
Update assets 2022-07-04 12:08:54 +02:00
Emile Rolley
22100d5b62 feat(runtime/api_web): add serialization for event + retrieveEvents in the API 2022-06-16 17:24:35 +02:00
Emile Rolley
e35e4a7cb4 feat(runtime): clean parse_raw_events + add documentation 2022-06-16 11:39:37 +02:00
Emile Rolley
092b57c898 feat(runtime): implement the raw_event parser 2022-06-13 17:59:00 +02:00
Emile Rolley
f932c45f97 docs: specify the log event structure 2022-06-09 15:49:08 +02:00
Emile Rolley
92ebb4194b refactor(api_web/runtime): runtime_value derive yojson_of 2022-05-25 14:26:58 +02:00
Louis Gesbert
551c9a6729 Allocation_logement: fix parentheses in formula
Changing the priorities broke the expression!

Here it was caught by the types; I hope there aren't other places where
it just changed the output without being caught by our tests...
2022-05-18 16:47:46 +02:00
Louis Gesbert
f9fc1a8e8b Formatting: sync with master 2022-05-12 15:10:55 +02:00
Denis Merigoux
96f1845afd
Merge branch 'master' into allocations_logement 2022-05-08 15:20:04 +02:00
Denis Merigoux
5ec91c7b00
Fix Python code and generated artefacts 2022-05-05 17:47:41 +02:00
Denis Merigoux
a72944a3ec
Merge branch 'master' into allocations_logement 2022-05-05 14:27:48 +02:00
Denis Merigoux
c7b84ca2d0
Merge pull request #244 from CatalaLang/c_backend
Bringing structure to the Lcalc AST
2022-05-05 14:22:26 +02:00
Denis Merigoux
a54a6826cf
Regenerate Python 2022-05-05 14:14:03 +02:00
Denis Merigoux
8a0d5d7916
Factoring, nitpicks and updates 2022-05-05 14:01:30 +02:00
Romain PRIMET
c1eb835f23
autopep8 2022-05-05 14:01:09 +02:00
Romain PRIMET
c782fff1c8
fail on errors (got bitten by this) 2022-05-05 14:01:09 +02:00
Romain PRIMET
6b30fd0142
fix imports 2022-05-05 14:01:09 +02:00
Romain PRIMET
f56133d442
reference runtime package in Makefile and requirements 2022-05-05 14:01:09 +02:00
Romain PRIMET
268d4b2dfb
rename dependencies to requirements (most common name for pip-installable list of deps) 2022-05-05 14:01:09 +02:00
Romain PRIMET
39be8b085b
invoke venv through its python module name for portability 2022-05-05 14:01:09 +02:00
Romain PRIMET
17f8e4a5f1
start drafting runtime package structure 2022-05-05 14:01:09 +02:00
Romain PRIMET
cde81f9235 autopep8 2022-04-29 21:37:23 +02:00
Denis Merigoux
aaa6a5d3a6
Merge branch 'master' into allocations_logement 2022-04-29 21:29:07 +02:00
Denis Merigoux
34bd6dcab0
I don't want to declare type stubs for gmpy2 2022-04-29 21:23:27 +02:00
Denis Merigoux
78e8275d5e
Adds a decimal rounding operator 2022-04-29 21:18:15 +02:00
Romain PRIMET
5065108407 fail on errors (got bitten by this) 2022-04-26 21:28:57 +02:00
Denis Merigoux
d79e6c974d
Fix last bugs 2022-04-26 16:22:47 +02:00
Romain PRIMET
75f1ea3d5e fix imports 2022-04-21 18:15:02 +02:00
Romain PRIMET
7992d5905b reference runtime package in Makefile and requirements 2022-04-21 12:46:48 +02:00