Louis Gesbert
36c8a7effc
Sort strings in natural order when they contain numbers
...
Seeing results sorted as 1 10 11 2 doesn't look nice.
2024-03-19 15:26:32 +01:00
Louis Gesbert
4cec981f62
Move global options of Cli to their own module
...
This resolves a dependency cycle that would forbid `Cli` from using the modue
`File`, which was annoying.
2024-03-19 15:18:35 +01:00
Louis Gesbert
3c03da4a50
file.ml: add a function to cleanup relative paths
2024-03-14 14:04:52 +01:00
Louis Gesbert
99004ab1d9
catala depends fixes
...
- automatically include the directories of listed files
- work for files that don't define modules
2024-03-13 18:15:50 +01:00
Louis Gesbert
9bf441ae31
'catala depends': allow specifying multiple files
...
The return is a topological order over their joint dependencies.
NOTE: the specified files are now included in the returns
2024-03-12 16:04:59 +01:00
Louis Gesbert
dc6bfae75c
Fixes for linking modules in the backends (in particular, Python)
2024-03-08 17:36:00 +01:00
Louis Gesbert
26c28bbd35
Fix line overflow message, and line offset errors
2024-03-08 17:36:00 +01:00
Louis Gesbert
95e3c4bedd
Ensure we create the necessary target directories before opening output files
2024-03-08 17:36:00 +01:00
Louis Gesbert
e68e1244a5
Fix complexity of some string functions
2024-03-08 17:36:00 +01:00
Louis Gesbert
ff06ddf40c
Fixing linking across modules for backends
...
- This adds a `catala depends` command that recursively tracks module dependency.
It can then be used by Clerk for linking.
- Generation of cmo object files are added for OCaml (we only built native
objects, but jsoo requires bytecode).
- Some fixes to the generation of value embed/deembed shims (related to types
coming from different modules ; add support for options ; etc.)
2024-03-08 17:36:00 +01:00
Louis Gesbert
70cbfdb9ac
Add a CATALA_INCLUDE env variable
...
It'll help while we wait for the implementation of project-wide specifications.
2024-03-08 17:36:00 +01:00
Louis Gesbert
bc3add57ec
Fix plugins lookup dir when Catala is installed to PATH
2024-03-08 17:36:00 +01:00
Louis Gesbert
346f401523
Disambiguate enum constructors from current module in priority
2024-03-08 17:36:00 +01:00
Louis Gesbert
8b3d7fb64b
Repair the 'explain' plugin
2024-03-05 10:07:25 +01:00
Denis Merigoux
c2c46c431e
Adress @altgr's suggestion
2024-03-04 13:30:25 +01:00
Denis Merigoux
ad5dd6f2f6
Fix R compilation
2024-03-03 18:36:50 +01:00
Louis Gesbert
1ea77201ff
Lcalc interpreter: fix passing of context arguments
2024-02-26 14:56:43 +01:00
Louis Gesbert
07b71656e7
Native/interpreter interface: handle option types
2024-02-26 14:56:43 +01:00
Louis Gesbert
ba9fc85b84
Make exception output consistent across the interpreters
2024-02-26 14:56:43 +01:00
Louis Gesbert
4a049080a4
CLI: replace interpret_lcalc
by interpret --lcalc
...
This will make it easier when running tests to just toggle the different flags
2024-02-26 14:56:43 +01:00
Louis Gesbert
97ae62384e
Add externals to scalc, working test with Python backend
2024-02-26 14:56:43 +01:00
Louis Gesbert
589833bca7
Make plugin load failures less verbose
...
In general you don't care unless you may have attempted to use one.
2024-02-26 14:56:43 +01:00
Louis Gesbert
e0928677b1
Small ocaml/js output rehaul
...
Print to json directly rather than depend on yojson and a ppx.
Note: this should be tested with the website in order to validate that the Json
output is 1-to-1.
(a second step could be to simplify this output, now that it's manual)
2024-02-21 11:28:56 +01:00
Louis Gesbert
4ee4992b54
Tweak multi-module LaTeX output
2024-02-16 16:36:15 +01:00
Louis Gesbert
f09edf443e
Fix typo
2024-02-16 16:12:35 +01:00
Louis Gesbert
60371189ab
Allow generation of one latex file from multiple sources
2024-02-15 20:54:24 +01:00
Louis Gesbert
5128da2ebe
Correctly fail if extra arguments are supplied
2024-02-15 20:54:14 +01:00
Louis Gesbert
18ec4b3dd3
LaTeX backend: fix module name escaping
2024-02-15 20:54:14 +01:00
Louis Gesbert
eb4ba114d2
Add test for literate LaTeX output
2024-02-15 14:53:26 +01:00
Louis Gesbert
a2d82d01f5
pandoc: disable highlight of custom fenced blocks for now
2024-02-15 13:54:44 +01:00
Louis Gesbert
23287ef817
Literate output: add info about modules
2024-02-15 13:54:44 +01:00
Louis Gesbert
2f2924944a
Syntax: add keywords in front of list filtering / arg-extremum
...
Closes #574
2024-02-14 13:55:03 +01:00
Louis Gesbert
bf0ef0b1f5
Allow access to intermediate variable states
...
Through the syntax `var_name state state_name`.
Addresses #567 , but
- requires documentation
- explicitely accessing states of the variable being defined is not allowed at
the moment (warning proposed in #567 requires a whole-expression check, which
is better done some place else entirely)
2024-02-12 18:15:48 +01:00
Louis Gesbert
afcc435593
CI: fix the check for bad promoted files
2024-02-12 16:44:14 +01:00
Louis Gesbert
721597a70d
Small additional simplification
2024-02-12 15:39:29 +01:00
Louis Gesbert
9ca952b518
Fix building of plug-ins
2024-02-12 10:48:12 +01:00
Louis Gesbert
e308ff8d02
Generalise the definition of lists of nested binders
2024-02-09 18:33:41 +01:00
Louis Gesbert
c124943a6e
Repair broken unit-test
2024-02-09 18:32:19 +01:00
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
Louis Gesbert
d3e7c565a9
Closure conversion: use multiple let-in
2023-12-19 17:30:32 +01:00
Louis Gesbert
5384394a72
Fix typing upon detuplification
2023-12-19 17:30:32 +01:00
Louis Gesbert
a2efc94fd2
Register the option type in ctx when used in lcalc
2023-12-19 17:30:28 +01:00
Louis Gesbert
a1c1a7756f
Update invariant tests outputs
2023-12-19 17:27:44 +01:00
Louis Gesbert
2823795f9f
AST change: more specific application
...
As part of making tuples first-class citizens, expliciting the arity upon
function application was needed (so that a function of two args can
transparently -- in the surface language -- be applied to either two arguments
or a pair).
It was decided to actually explicit the whole type of arguments because the cost
is the same, and this is consistent with lambda definitions.
A related change done here is the replacement of the `EOp` node for operators by
an "operator application" `EAppOp` node, enforcing a pervasive invariant that
operators are always directly applied. This makes matches terser, and highlights
the fact that the treatment of operator application is almost always different
from function application in practice.
2023-12-19 17:27:40 +01:00
Denis Merigoux
af16be501a
Remove useless optimizations caught just after
2023-12-19 17:26:36 +01:00
Denis Merigoux
9d9a2c4496
Start to implement proper monomorphization
2023-12-19 17:26:17 +01:00
Louis Gesbert
94ebc1b65e
Allow deconstruction of tuples using let in
2023-12-19 17:25:44 +01:00
Louis Gesbert
df3ab64fe9
Add tuples to the surface language
...
No helpers to destruct them at the moment
2023-12-19 17:25:44 +01:00
Louis Gesbert
fb51f58261
Optimise away trivially-true errors-on-empty
2023-12-19 16:10:11 +01:00
Louis Gesbert
ea4e191f27
Add optimisation to skip variable aliasings
...
This particularly of effect to the code introduced by closure conversion.
2023-12-19 16:07:22 +01:00
Louis Gesbert
7233ec403a
Printer: add parens after constructors
2023-12-19 16:07:22 +01:00
Louis Gesbert
ad0afa2f64
Small interpreter optimisation
...
This is unholy, but we're manually bringing a typing proof so it may be
acceptable...
2023-12-19 16:07:22 +01:00
Louis Gesbert
e123d7eb95
Change type syntax of collection
into list of
2023-12-19 15:26:44 +01:00
Louis Gesbert
3779a249db
Unify all CLI arguments to use -
rather than _
...
it's more common on UNIXes and the mix was unpleasant.
2023-12-19 15:25:37 +01:00
Denis Merigoux
85bbb7be1c
Add monomorphizing option
2023-12-19 15:01:06 +01:00
Denis Merigoux
9358ad945e
Better type translation in closure conversion
2023-12-19 14:31:57 +01:00
Denis Merigoux
e6a35f31b6
Fixes #551
2023-12-19 13:39:24 +01:00
Denis Merigoux
366c351930
Correctly compiles let bindings in expressions
2023-12-19 12:03:23 +01:00
Denis Merigoux
0323e71edb
Default types should be eliminated in compile_with_exceptions
2023-12-18 15:23:08 +01:00
Denis Merigoux
4eead4850b
There are no more defaults in type after compile_with_exceptions...
2023-12-18 15:14:28 +01:00
Denis Merigoux
91f8451899
Better beta-reduction
2023-12-18 14:49:43 +01:00
Denis Merigoux
35f829cd65
Fix default optimisation
2023-12-18 14:42:58 +01:00
Denis Merigoux
1f91c16e43
Fix little bug
2023-12-13 16:40:22 +01:00
Denis Merigoux
5c49581207
Compiling simple program correctly to C
2023-12-13 11:07:08 +01:00
Denis Merigoux
827fcef469
More progress but enums also require no struct literals
2023-12-12 18:21:20 +01:00
Denis Merigoux
adfb9297d3
Progress on compiling
2023-12-12 16:25:02 +01:00
Denis Merigoux
d88f67bb2c
Progress
2023-12-12 16:08:40 +01:00
Denis Merigoux
7e221b29eb
Gets C89 struct initialization right
2023-12-11 17:28:32 +01:00
Denis Merigoux
37ab4187bd
Almost there with structs
2023-12-11 17:08:32 +01:00
Denis Merigoux
aca1d0e712
Fields in AST nodes
2023-12-11 15:59:47 +01:00
Denis Merigoux
3711026a4f
Beginning to compile
2023-12-11 14:47:09 +01:00
Denis Merigoux
5b7470fd0d
Compile HandleDefaultOpt specially
2023-12-11 14:34:31 +01:00
Denis Merigoux
f072694e50
Trying to progress
2023-12-11 13:56:13 +01:00
Denis Merigoux
79a261bb47
Restore CI
2023-12-11 11:44:25 +01:00
Denis Merigoux
c61bdbc5d7
Setting up special compilation
2023-12-11 11:31:51 +01:00
Denis Merigoux
4e8d2ef219
Beginning to compile specially HandleDefaultOp, Map, Fold, etc. for C
2023-12-11 11:31:51 +01:00
Denis Merigoux
4f7b678cd7
Making progress and fixing bugs
2023-12-11 11:31:51 +01:00
Denis Merigoux
192e50540b
Correctly compile function pointer types
2023-12-11 11:31:51 +01:00
Denis Merigoux
4d969e13c5
Enum type
2023-12-11 11:31:51 +01:00
Denis Merigoux
2eaac39bb1
Some progress
2023-12-11 11:31:51 +01:00
Denis Merigoux
ad3e140e88
Progress on C backend
2023-12-11 11:31:51 +01:00
Denis Merigoux
5f045110b9
Add tuples to Scalc
2023-12-11 11:31:51 +01:00
Denis Merigoux
6652dc8df2
Add C backend command
2023-12-11 11:31:45 +01:00
Louis Gesbert
5b1462d529
Clerk: allow to include non-yet-existing directories
...
Useful when you have wide `-I` options that not all targets may depend on.
2023-12-08 13:56:31 +01:00
Louis Gesbert
a988ad473b
Fix handling of embedded context through modules
...
Exceptions raised by the interpreter from within the native modules were not
handled correctly.
2023-12-08 13:56:18 +01:00
Louis Gesbert
509ce9788a
Document and first test for externals ( #538 )
2023-12-07 16:06:25 +01:00
adelaett
b5e7b297aa
typo fixing
2023-12-07 13:48:46 +01:00
adelaett
9f4a238a4a
Fix error messages for unexpected types.
...
do not retype the terms in the cases where checking invariant is not mandatory.
2023-12-07 13:45:50 +01:00
adelaett
934ab328ec
invariant checking is now available without printing the ast using the typecheck subprogram
2023-12-07 11:27:14 +01:00
adelaett
e1bda33e07
fmt
2023-12-07 11:27:14 +01:00
adelaett
030705eacd
Make the typing invariant more precise.
2023-12-07 11:27:14 +01:00
adelaett
67e36dcf42
Adding Typing Invariant for TDefault
...
Added a new type safety invariant to ensure that the type `TDefault` can only appear in certain positions,
* On the left-hand side of an arrow with arity 1, as the type of a scope (for scope calls).
* At the root of the type tree (outside a default).
* On the right-hand side of the arrow at the root of the type (occurs for rentrant variables).
This is crucial to maintain the safety of the type system, as demonstrated in the formal development.
The invariant was checked on all tests cases and on family and housing benefits.
Adjusted inversion invariant about app to handle external objects as well.
2023-12-07 11:27:14 +01:00
Denis Merigoux
2486fbcfb5
Fix LaTeX weaving failing with code blocks ( #544 )
2023-12-07 11:08:04 +01:00
Denis Merigoux
628cbc4fec
Fix #543
2023-12-06 16:58:38 +01:00
Louis Gesbert
7160093682
Allow scope execution in compiled ocaml executables
2023-12-06 11:06:54 +01:00
Louis Gesbert
54d956823b
Some module fixes
2023-12-06 11:06:54 +01:00
Louis Gesbert
9a255522be
Document and first test for externals
...
Also some fixes for Clerk to properly support them
2023-12-06 11:06:54 +01:00
Louis Gesbert
0d5759d99c
Allow pre-declarations without an expression for topdefs
...
it allows for better splitting between metadata and code (even if the type has
to be repeated at the moment)
2023-12-05 16:21:04 +01:00
Louis Gesbert
e689f0c47b
Small cleanup and doc on the module handling refactor
2023-12-05 16:01:56 +01:00
Louis Gesbert
1ae955b504
Reformat
2023-11-30 23:53:38 +01:00
Louis Gesbert
8df49dcea2
More tests and some fixes
2023-11-30 23:49:19 +01:00