Commit Graph

838 Commits

Author SHA1 Message Date
Louis Gesbert
0dbc4c8c35 Separate type ordering from scopelang->dcalc transformation
it's now done explicitely from the driver, which allows to do it before typing
and is more consistent; the information was already forwarded to the later
compilation stages separately from the program AST anyway.
2022-10-04 14:50:37 +02:00
Louis Gesbert
ff76d0498f Make the typer use (and check) already existing annotations, if any 2022-10-04 14:50:37 +02:00
Louis Gesbert
76d1c1cc93 Dcalc.Optimization should reasonably preserve types
since it only does reductions while preserving marks. The patch is mostly a
renaming from `pos` to `mark`
2022-10-04 14:50:37 +02:00
Louis Gesbert
4d8bc20fcd Test new typing 2022-10-04 14:50:37 +02:00
Louis Gesbert
3b4b070aaa Fix typing 2022-10-04 14:50:37 +02:00
Louis Gesbert
2955ef3235 Implement typing at the scopelang level 2022-10-04 14:50:37 +02:00
Louis Gesbert
9f7a0f6078 Fix naming error in interface
Hmm I used too much `sed` and overlooked this one
(patch looks big because of reformatting, but it's mostly just `naked_expr`→`expr`)
2022-10-04 14:50:37 +02:00
Louis Gesbert
05f4bb3537 Typing: simplify interface, split code in smaller functions 2022-10-04 14:50:37 +02:00
Louis Gesbert
51f79af13e Generalise the types to allow scopelang ASTs to be typed 2022-10-04 14:50:37 +02:00
Louis Gesbert
0ad51b7aec Unify outermost types first in Typing.top_down
It doesn't actually change the error output much, but is more sound, and allowed
to fix a few quirks in the code.
2022-10-04 14:50:37 +02:00
Louis Gesbert
a8816eb9e4 Fix parser message that didn't make sense to me
I had the message appear after a `integer_to_decimal` not followed by `of`, but
might it happen in other cases ?
2022-10-04 14:50:37 +02:00
Louis Gesbert
af9f497ffb Implement typing of desugared/scopelang and lcalc terms
Note that this is incomplete in the case of desugared/scopelang because we only
have typing for expressions yet, and the scope/program structure is different.

The code allows passing an environment of types for scope/subscope variables in
order to resolve `ELocation` terms, but that's unused until we implement
scopelang typing at the scope level.
2022-10-04 14:50:37 +02:00
Louis Gesbert
b37a6c3703 Generalise the typer
This moves dcalc/typing.ml to shared_ast, and generalises the input type, but
without yet implementing the extra cases (these are all `assert false`): it's
just a first step.
2022-10-04 14:50:37 +02:00
Louis Gesbert
0bb9cce341 Simplify a few mark operations 2022-10-04 14:50:37 +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
Louis Gesbert
a41de29293 Improve typing error message on <any> array
- don't print variable id on type variables, there should be no ambiguity
- print "array" as "collection" to match the language
- print just "collection" for "'a collection", which makes sense english-wise
2022-09-26 14:29:15 +02:00
Louis Gesbert
c18de3b980 Tweak the order in which typing is done 2022-09-26 14:11:25 +02:00
Louis Gesbert
76569bb1af Fix position on type error concerning sub-scope variable 2022-09-26 14:11:25 +02:00
Louis Gesbert
498429e4b7 Fix type-checking error getting delayed
The issue was coming from Bindlib: it stores variable bindings as closures, so
`Bindlib.box_apply f bx` actually delays the application of `f` until the term
is substituted or unboxed (likely long after we are out of the `try..with`
block).

The proposed fix is to make sure we run the wrapper outside of bindlib
applications, on explicitely unboxed terms.
2022-09-26 14:11:25 +02:00
Louis Gesbert
8bf6b5b821 Type arrow return types first 2022-09-26 14:11:25 +02:00
Louis Gesbert
2c3be946ec Keep type positions on the right-hand side upon unification of types
This should result in more predictable error messages. Right-hand is arbitrary,
but has been found empirically to give better results.
2022-09-26 14:11:25 +02:00
Denis Merigoux
f1d0831d86
LégiFrance<->Catala connector (#329) 2022-09-19 11:14:21 +02:00
Aymeric Fromherz
7f07274c1f Ignore unfound (i.e., internal) variables during Z3 model printing 2022-09-13 15:54:26 +02:00
Aymeric Fromherz
fee64d6f6f format 2022-09-13 10:37:30 +02:00
Aymeric Fromherz
b7854eb6f3 Z3Backend: Use type information inside AST node for match translation 2022-09-13 10:33:02 +02:00
Aymeric Fromherz
ea13981c5d Match annotation type in io.mli and in Z3 backend 2022-09-12 18:10:02 +02:00
Aymeric Fromherz
0592cdab2a Z3encoding: Use auxiliary variable for encoding type-generic EMatch 2022-09-12 17:52:55 +02:00
Denis Merigoux
8445174a5b
Improvements to expiration checking 2022-09-07 17:14:22 +02:00
Denis Merigoux
d7e219b0dd
Correct test output for proof mode 2022-09-06 14:10:32 +02:00
Denis Merigoux
84b994b521
Bug caught with proof mode 2022-09-05 17:35:44 +02:00
Denis Merigoux
01e333b833
Use dates_calc library (#306)
This is a WIP. Current version 0.0.2 of `dates_calc` is in the process of being published, so I guess the CI should fail currently.

- [x] Test current implementation
- [x] I commented out the `duration / duration` operator, can we remove it?
- [x] Need to add support for first and last day of month
- [x] Finish porting the Z3 backend to dates_calc
2022-09-05 15:57:08 +02:00
Denis Merigoux
6130151c8e
Fix bug and typos 2022-09-05 14:50:37 +02:00
Raphaël Monat
973c346328 Add support for is_leap_year in z3 backend and runtime 2022-09-05 09:28:58 +02:00
Raphaël Monat
f60cfcc435 Merge branch 'master' of github.com:CatalaLang/catala into dates_calc_lib 2022-08-30 15:14:51 +02:00
Raphaël Monat
39110f53a5 Fix missing case 2022-08-30 15:06:45 +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
Louis Gesbert
84c78a234f
Make desugared and scopelang use the 'a mark type for AST annotations
This gives further uniformity in their interfaces and allows more common
handling.

The next step will be for all the `Expr.make_*` functions to work on expressions
annotated with the `'a mark` type, correctly propagating type information when
it is present. Then we could even imagine early propagation of type
information (without complete inference), which could for example be used for
overloaded operator disambiguation.
2022-08-29 11:29:24 +02:00
Louis Gesbert
5bda9e98d0
Small cleanup
Remove unneeded types, e.g. provisions for scalc
2022-08-29 11:29:24 +02:00
Louis Gesbert
7e0d24efd2
Make all supertypes use ('a, 't) gexpr as parameter instead of naked_gexpr 2022-08-29 11:29:24 +02:00
Louis Gesbert
5e9c3d630e
Same treatment for typ and marked_typ 2022-08-29 11:29:24 +02:00
Louis Gesbert
f09451bf6b
Add a type alias for clarity of Shared_ast.Expr 2022-08-29 11:29:24 +02:00
Louis Gesbert
be58610061
Rename marked_expr -> expr, expr -> naked_expr throughout
Since the marked kind is used throughout, this should be more clear
2022-08-29 11:29:23 +02:00
Louis Gesbert
8f7ba5ccaf
Rename marked_gexpr -> gexpr, gexpr -> naked_gexpr
Since the marked kind is used throughout, this should be more clear
2022-08-29 11:29:23 +02:00
Louis Gesbert
e10771c187
Make all supertypes use ('a, 't) gexpr as parameter instead of naked_gexpr 2022-08-29 10:57:21 +02:00
Louis Gesbert
a9c8bab2b3
Same treatment for typ and marked_typ 2022-08-29 10:57:21 +02:00
Louis Gesbert
15dfef9809
Add a type alias for clarity of Shared_ast.Expr 2022-08-29 10:57:21 +02:00
Louis Gesbert
0a23dc526d
Rename marked_expr -> expr, expr -> naked_expr throughout
Since the marked kind is used throughout, this should be more clear
2022-08-29 10:57:21 +02:00
Louis Gesbert
493b6703a7
Rename marked_gexpr -> gexpr, gexpr -> naked_gexpr
Since the marked kind is used throughout, this should be more clear
2022-08-29 10:57:21 +02:00
Denis Merigoux
aaca280ccc
Continuing the AST factorisation to scopelang and desugared (#321)
(on top of #320, waiting for it to be merged for rebase)
2022-08-29 10:54:17 +02:00
Denis Merigoux
e41e0f9dcc
Fix line length and display lines of code 2022-08-26 12:05:22 +02:00
Louis Gesbert
ef36b18dfe And finally the desugared AST as well 2022-08-26 11:31:14 +02:00
Louis Gesbert
01cc957b3b Used shared_ast for scopelang expressions 2022-08-26 11:31:14 +02:00
Louis Gesbert
a6702808ef Handle additional scopelang cases in helper functions 2022-08-26 11:31:14 +02:00
Louis Gesbert
49e37c71b4 Add scopelang / desugared cases to the shared AST expressions 2022-08-26 11:31:14 +02:00
Louis Gesbert
54eee2edea Rationalise the tuple / enum types
This will allow to unify with types used earlier in the
pipeline (`Scopelang.Ast.typ`).

It seems cleaner! But some areas may warrant a later clean-up, in particular
handling of options and their types in the backends, or possible name conflicts
of structs/enums with built-in types when printing.
2022-08-23 15:48:06 +02:00
Louis Gesbert
4caf828e48 Additional cleanup/fixes on the compiler refactoring
following review ^^
2022-08-23 00:13:02 +02:00
Louis Gesbert
576e0fb3ff Factorise AST printers
Note that there were significant differences between the two printers (see the test diff!). Overall the `dcalc` one seemed newer so that's what I took, with only the required additions from `lcalc` (exceptions, raise and catch)
2022-08-22 19:28:27 +02:00
Louis Gesbert
ae2801be6d Move mode handling code from dcalc to shared_ast
Handling code should now be reasonably well sorted between `Shared_ast.{Var,Expr,Scope,Program}`

The function parameters (e.g. `make_let_in`) could be removed from the
scope handling functions since now the types are compatible, which
makes them much easier to read.
2022-08-22 19:28:27 +02:00
Louis Gesbert
d02c02e352 Fix some warnings 2022-08-22 19:28:27 +02:00
Louis Gesbert
8e7f65d204 Split Shared_ast.Expr of scope and program functions 2022-08-22 19:28:27 +02:00
Louis Gesbert
4bb49c14f1 Simplify some type aliases 2022-08-22 19:28:27 +02:00
Louis Gesbert
a74ccd30eb Add some documentation on the new lib 2022-08-22 19:28:27 +02:00
Louis Gesbert
06dbab74d2 reformat 2022-08-22 19:28:27 +02:00
Louis Gesbert
2b6ee8dd4b Leverage the shared AST: big cleanup (part I) 2022-08-22 19:28:21 +02:00
Louis Gesbert
988e5eff1c Split the shared AST into a separate lib 2022-08-22 19:16:28 +02:00
Denis Merigoux
4455b8fb0c
Stub before correct replacement 2022-08-19 15:21:38 +02:00
Denis Merigoux
755b1212a2
Remove division durations 2022-08-19 15:21:29 +02:00
Denis Merigoux
e5aed3efcb
Merge branch 'master' into rmonat_dates_calc_lib 2022-08-19 14:59:46 +02:00
Denis Merigoux
b5c4608ce1
Message 2022-08-19 14:43:56 +02:00
Raphaël Monat
0b73fbbac4 Add support for first and last day of month operators 2022-08-18 21:22:50 +02:00
Denis Merigoux
7ee971c4e1
Remove unused type definitions 2022-08-16 14:33:37 +02:00
Denis Merigoux
437be673ce
Merge branch 'master' into aides_logement 2022-08-16 14:25:06 +02:00
Denis Merigoux
2c40802c57
Fix again line numbers in HTML 2022-08-16 11:46:20 +02:00
Denis Merigoux
efa7cec4c1
Merge pull request #315 from AltGr/ast-factorisation
Factorise ASTs (between dcalc and lcalc)
2022-08-16 11:42:51 +02:00
Denis Merigoux
2ae0efa5dd
Fix subtle bug with the default false value for conditions 2022-08-15 16:47:36 +02:00
Denis Merigoux
1aeb47effd
Fix uncaught type error 2022-08-15 16:20:31 +02:00
Louis Gesbert
0b0e774d1c More factorisation, in particular for variables 2022-08-12 17:18:06 +02:00
Louis Gesbert
ebf97a0995 Pass-specific literals 2022-08-12 16:55:32 +02:00
Louis Gesbert
b5579cde3d Generalise the expressions between dcalc and lcalc
The huge benefit of this approach is that almost no changes are needed and we get compatible types between dcalc and lcalc, allowing to deduplicate a few functions.

It might not be the best in the long run: there are still benefits in factorising small parts of the AST as suggested in #157, and this forces a central AST definition that makes the nanopass-like approach a bit less legible.

Still, I think it's a step in the right direction and it doesn't really lock us in keeping to use the big GADT (as the minimal cascade of changes show).
2022-08-12 16:55:30 +02:00
Denis Merigoux
c6e448a9b7
Correctly escape character in HTML weaving 2022-08-12 09:51:43 +02:00
Denis Merigoux
62b984c83c
Don't print functions in interpreter 2022-08-11 18:13:25 +02:00
Denis Merigoux
da06bedaca
Fix HTML line numbers 2022-08-11 16:15:52 +02:00
Denis Merigoux
038e6068e6
Small improvements to housing benefits 2022-08-10 18:13:07 +02:00
Denis Merigoux
3a3c08ba7c
Fix LegiFrance link generation 2022-08-10 10:52:46 +02:00
Denis Merigoux
228b6c830a
Fix line numbers in LaTeX and HTML with leading comments in code 2022-08-10 10:45:49 +02:00
Denis Merigoux
a77fa65f9c
Documentation about plugins 2022-08-09 15:00:13 +02:00
Louis Gesbert
f35f18b295 Add local 'let in' bindings 2022-08-09 12:17:31 +02:00
Denis Merigoux
03e598128a
Bumping version number 2022-08-08 17:26:07 +02:00
Denis Merigoux
d03d82a0e7
Correctly count columns 2022-08-08 17:25:08 +02:00
Raphaël Monat
3e71f25bfe Post merge fixes on using dates_calc 2022-08-06 17:49:06 +02:00
Raphaël Monat
ffd2e1dec3 Merge branch 'master' into dates_calc_lib 2022-08-06 17:26:55 +02:00
Raphaël Monat
4f12338d49 Switch from calendarlib to in-house dates_calc 2022-08-06 17:07:01 +02:00
Denis Merigoux
4d465b33b4
Helpful error message when trying to interpret a scope with arguments 2022-08-06 13:35:17 +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
eacc4dcc90 fix(html): sanitize href of line links in code blocks 2022-08-05 10:55:48 +02:00
Emile Rolley
ba620fca28 ocamlformat: new break-infix rule 2022-08-05 10:55:48 +02:00
Emile Rolley
d85812109c refactor(compiler): remove the camomile dependency due to the new Utils.String_common module based on Ubase 2022-08-05 10:55:45 +02:00
Emile Rolley
03aebf7f1c feat(backends/html): improve the code generation with ToC and details tags 2022-08-05 10:55:45 +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
e63860de4b Disable ocamlformat on api_web 2022-08-04 17:36:50 +02:00
Louis Gesbert
bc8eda581c Add a script generating static builds
We have an obvious limitation: static builds won't support plugins. We
could resort to the classic method and do normal builds but on an old
distrib to dodge compatibility issues.

That would still be compatible with statically linking the more specific
libs, like e.g. z3.
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
0abbb3e29b Syntax: tweak priority of 'set contains elt'
(the other way around was creating a conflict !)
2022-08-02 10:02:03 +02:00
Emile Rolley
2da94b88c2 fix(compiler): use Plugin.extension instead of the hardcoded ".ml" one 2022-08-01 10:28:38 +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
21af0c8c04 refactor(compiler): split web plugin into api_web and json_schema + factorize some util functions 2022-07-29 18:42:47 +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
ae3852fa12 feat(plugins/web): generate minimal working JSON schema from a given scope 2022-07-29 18:42:41 +02:00
Emile Rolley
599126a7ce feat(plugins/web): retrieve required types definitions from scope input 2022-07-29 18:42:41 +02:00
Emile Rolley
32ec53d918 refactor(plugins): jsoo -> web 2022-07-29 18:42:41 +02:00
Emile Rolley
6ce6ea8afc refactor(plugins): add scope as argument for the apply function 2022-07-29 18:42:41 +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
4845196b5b Add source positions in all backends exceptions 2022-07-29 18:42:14 +02:00
Denis Merigoux
974c2b8d58 Fix bug in Python backend 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
8d3e283669 Fix some bugs of JSOO plugin 2022-07-28 15:02:43 +02:00
Louis Gesbert
3987e446e9
Add polish translation for new "contains" keyword 2022-07-28 10:34:37 +02:00
Louis Gesbert
6d41818e0a Change syntax for set membership predicate
Before: `ELEMENT in SET`; now: `SET contains ELEMENT`

Using the `in` keyword was causing conflicts and blocking #203.
Current proposal has `contient` for the French syntax, and is untranslated (`contains`) for Polish.
2022-07-27 14:34:58 +02:00
Louis Gesbert
922b77abc7 Cli: allow standard option --color=always|never|auto to control styling 2022-07-27 10:42:35 +02:00
Denis Merigoux
d17ac0bc39
More nitpicks 2022-07-22 18:04:16 +02:00
Denis Merigoux
fa55a83fb4
Merge branch 'master' into 290-jsoo-wrapper-plugin 2022-07-22 17:54:51 +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
ad0efd3447 refactor(ocaml): wrap enum type inside their own module like struct ones 2022-07-22 16:52:56 +02:00
Emile Rolley
3ab5129572 feat(jsoo): add conversion fun generation (except mutiple cons args) 2022-07-22 16:52:56 +02:00
Emile Rolley
677ff92ae6 feat(utils): add File.ocamlformat_file_opt 2022-07-22 16:52:56 +02:00
Emile Rolley
5f27334bec feat(jsoo): gen conv functions from and to jsoo type 2022-07-22 16:52:56 +02:00
Emile Rolley
0a9e563450 refactor(to_ocaml): format_to_struct_type -> format_to_module_name 2022-07-22 16:52:56 +02:00
Emile Rolley
3dcf856ec6 refactor(cli): add Cli.call_unstyled 2022-07-22 16:52:56 +02:00
Emile Rolley
b2bba6eaf0 feat(jsoo): factorize log events related function to the object eventManager 2022-07-22 16:52:56 +02:00
Emile Rolley
37a8cf7090 fix(rebase): changes Lcalc and Dcalc AST manipulation according #272 2022-07-22 16:52:56 +02:00
Emile Rolley
0c180e12f9 refactor(runtimes): add runtime_ocaml and runtime_jsoo in the catala package 2022-07-22 16:52:56 +02:00
Emile Rolley
cd33ed9de7 feat(plugins/jsoo): now generate both .ml and _web_api.ml file 2022-07-22 16:52:56 +02:00
Emile Rolley
59f50f95e8 refactor(plugins/jsoo): use To_ocaml function directly by extending its interface 2022-07-22 16:52:56 +02:00
Emile Rolley
c09b457988 refactor(runtimes): add move the OCaml runtime into runtimes/ocaml 2022-07-22 16:52:56 +02:00
Emile Rolley
cda3bfb3aa feat(plugins/jsoo): format type declaration 2022-07-22 16:52:56 +02:00
Denis Merigoux
dc00ce8957
Merge branch 'master' into aides_logement 2022-07-22 16:49:01 +02:00
Denis Merigoux
b7c468bd1e
Fix faulty unboxing 2022-07-22 16:18:55 +02:00
Denis Merigoux
522deb50c2
Factorizing Dcalc.program 2022-07-22 15:49:57 +02:00
Denis Merigoux
0304602433 Trying to fix Bindlib unboxing bug [skip ci] 2022-07-22 12:31:05 +02:00
Denis Merigoux
85144c35fb Simplify default tree encoding 2022-07-22 12:31:02 +02:00
Denis Merigoux
3895743f20 Cleaned code for generating exception graph, now correct and fully general
Missing some encoding optimizations
2022-07-22 12:25:41 +02:00
Denis Merigoux
85cb2d5c8d Starting debug 2022-07-22 12:11:34 +02:00
Denis Merigoux
100c84a741
Allow negative literals 2022-07-21 14:14:22 +02:00
Denis Merigoux
dcf80f4bec
Adding first_day_of_month and last_day_of_month 2022-07-21 14:14:04 +02:00
Denis Merigoux
5bcee7ceba
Correctly generate HTML output 2022-07-20 15:35:26 +02:00
Denis Merigoux
58cb48fb28
Merge remote-tracking branch 'origin/master' into aides_logement 2022-07-20 11:20:00 +02:00
Denis Merigoux
6d224e1a41
Merge pull request #272 from AltGr/types-everywhere
Annotate the ASTs with type information everywhere
2022-07-20 11:07:17 +02:00
Louis Gesbert
e2e90cd080
Remove stale comment in dune file 2022-07-20 10:57:56 +02:00
Louis Gesbert
d9fbaa704b Restore some commented out code, add some comments 2022-07-19 21:41:55 +02:00
Louis Gesbert
b9099ac7a4 Use resolved types in type annotations
Adding an 'inferring' annotation type only used during typing
2022-07-19 18:47:00 +02:00
Denis Merigoux
793efb4682
In the process of switching some money types to decimal [skip ci] 2022-07-19 13:53:12 +02:00
Denis Merigoux
be373f0ff5
Added primitives money_to_decimal and decimal_to_money [skip ci] 2022-07-19 11:53:09 +02:00
Denis Merigoux
05115c7541
Help OCaml's type inference
Needed because of constructor name confusion
2022-07-14 15:29:50 +02:00
Denis Merigoux
fffa318144
Don't print functions on CLI tracing mode; they're too big 2022-07-13 17:27:08 +02:00
Louis Gesbert
61063b5234 Small cleanup and clarifying a dark spot of the Ast interface 2022-07-13 12:28:08 +02:00
Louis Gesbert
83de1a229b Mark the optimization passes as untyped
It's not expected to stay that way forever, but some additional effort will be required for them to preserve (or restore) types; until then, be safe and don't forward possibly incorrect information.
2022-07-13 12:17:43 +02:00
Emile Rolley
4991350b58 feat(backend/ocaml): disambiguate OCaml record names derived from Catala struct 2022-07-12 16:12:18 +02:00
Louis Gesbert
97120c4dc2 compiler/verification: force a typed AST as input 2022-07-12 15:57:50 +02:00
Louis Gesbert
7485c7f2ce Reformat 2022-07-11 17:42:34 +02:00
Louis Gesbert
985ecdac6d Bump required OCaml version to 4.13
This version of OCaml introduces [let-punning](https://v2.ocaml.org/manual/bindingops.html#ss:letops-punning)

It is just syntactic sugar, but OCamlformat makes use of it, without a configuration option, when the OCaml version permits.
This means that the same version of OCamlformat gives different results depending on the underlying OCaml version. Our options, if we want to keep the forced-format policy on the repository, are therefore:
- to disable it whenever binding operators are used (with this PR that's a lot of places, and this becomes too cumbersome, besides defeating the purpose)
- to force devs to use an earlier version of OCaml so that reformatting outputs something compatible
- to bump the minimum OCaml requirement

The latter is the simplest, but it can be reviewed if compatibility is required. Last option would be to report the issue to OCamlformat and hope that they provide a workaround...
2022-07-11 17:42:34 +02:00
Louis Gesbert
504f54c31e Rework type error reporting 2022-07-11 17:42:34 +02:00
Louis Gesbert
02fc255177 Typing scopes: bottom-up rather than top-down
it's better for error messages (and similar to how it was done before)
2022-07-11 17:42:34 +02:00
Louis Gesbert
18e86621d5 Port verification code to the AST changes 2022-07-11 17:42:34 +02:00
Louis Gesbert
5f882e35a2 dcalc ast: make the map function more polymorphic 2022-07-11 17:42:34 +02:00
Louis Gesbert
49efb5ddd7 Improve debugging, add backtraces (when recording is enabled) 2022-07-11 17:42:34 +02:00
Louis Gesbert
296a1de7dd Typing: add functions to type scopes without conversion to expr 2022-07-11 17:42:34 +02:00
Louis Gesbert
4eb5933ad0 Porting the interpreter to the marked AST 2022-07-11 17:42:30 +02:00
Louis Gesbert
6cc2e9a07b typing.ml: fix use of bindlib 2022-07-11 16:51:54 +02:00
Louis Gesbert
67179a793c Add type annotations on all AST nodes (first pass) 2022-07-11 16:51:54 +02:00
Louis Gesbert
513647cd32 AST simplification: remove redundant annotations
The AST structures track annotations (e.g., at the moment, source code
position information) in a lot of places. This patch tidies up a bit and
removes some duplication, ensuring a single level of annotation wrapping
at each AST recursion level.

This will be important when adding type information in these
annotations, because there will be consitency constraints to be ensured
and duplication is a likely source of mistakes.
2022-07-11 16:51:54 +02:00
Louis Gesbert
af0ac95682 Propagate renaming of Pos.mark* into module Marked
this patch is just a bunch of `sed` commands

```shell
cd compiler
sed -i 's/Pos.marked/Marked.pos/g' *.ml* **/*.ml*
sed -i 's/Pos.unmark/Marked.unmark/g' *.ml* **/*.ml*
sed -i 's/Pos\.get_position/Marked.get_mark/g' *.ml* **/*.ml*
sed -i 's/Pos\.same_pos_as/Marked.same_mark_as/g' *.ml* **/*.ml*
sed -i 's/Pos\.map_under_mark/Marked.map_under_mark/g' *.ml* **/*.ml*
sed -i 's/Pos\.mark/Marked.mark/g' *.ml* **/*.ml*
sed -i 's/Pos\.compare_marked/Marked.compare/g' *.ml* **/*.ml*
```
2022-07-11 16:51:54 +02:00
Louis Gesbert
481aea83e0 Generalise the type for AST node markings 2022-07-11 16:51:54 +02:00
Louis Gesbert
d7dbbde26f
Merge pull request #285 from CatalaLang/fix_192
Partially fix #192
2022-07-11 16:43:48 +02:00
Denis Merigoux
66a7d2f7a3 Fix test encoding 2022-07-08 15:37:01 +02:00
Denis Merigoux
fa0d94a2b6
Remove authors feature whose behavior is not satisfactory 2022-07-08 14:41:19 +02:00
Denis Merigoux
bdbf202a8d
Minimal implementation of https://github.com/CatalaLang/catala/issues/192#issuecomment-1178750411 2022-07-08 14:10:25 +02:00
Denis Merigoux
a34a330dc4
Fix breaklines in LaTeX 2022-07-06 17:37:42 +02:00
Denis Merigoux
5e45940e1b
Merge branch 'master' into allocations_logement 2022-07-06 16:43:14 +02:00
Emile Rolley
97cf14b3f5 refactor(runtime): ignore function definition while parsing raw events 2022-06-23 17:35:11 +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
9b5779ed62 feat(runtime): format_events -> pp_events (Done). 2022-06-15 19:32:45 +02:00
Emile Rolley
d82ecb5f12 fix(compiler/log): retrieve types of input and output function calls 2022-06-15 14:34:15 +02:00
Emile Rolley
d1a7be688c feat(runtime): start to implement format_events 2022-06-14 17:42:13 +02:00
Emile Rolley
092b57c898 feat(runtime): implement the raw_event parser 2022-06-13 17:59:00 +02:00
Emile Rolley
84f79be7b7 feat(runtime): define the event type 2022-06-09 17:17:12 +02:00
Emile Rolley
f7787ff80d fix(compiler): fix line num for HTML generation 2022-06-08 17:21:15 +02:00
Denis Merigoux
34fd8a0bb2
Print a position when logging assignment of a default false for a condition 2022-06-03 17:50:03 +02:00
Denis Merigoux
ab0f4eb28c
Merge branch 'master' into allocations_logement 2022-06-01 17:28:54 +02:00
Denis Merigoux
6e4e646dd8
More robust implementation of duration multiplication 2022-06-01 15:15:22 +02:00
Denis Merigoux
878de024b7
Better error message 2022-06-01 11:13:14 +02:00
Jonathan Protzenko
0e68c07567 Reset parser messages 2022-06-01 10:26:14 +02:00
kescher
db9eec3b9f add support for duration multiplication
Signed-off-by: Jonathan Protzenko <protz@microsoft.com>
2022-05-31 11:17:38 -07:00
Denis Merigoux
89db6d9b69
Fix logging regression involuntarily introduced by #268 2022-05-31 16:09:32 +02:00