Commit Graph

311 Commits

Author SHA1 Message Date
Louis Gesbert
bc90a7b890 Add (internally) a map2 operator 2024-01-26 11:22:12 +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
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
Louis Gesbert
12f208b3fc Adding tuples: fixes following review 2024-01-08 12:16:07 +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
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
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
Denis Merigoux
e6a35f31b6
Fixes #551 2023-12-19 13:39:24 +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
1ae955b504 Reformat 2023-11-30 23:53:38 +01:00
Louis Gesbert
3649f92975 Rework resolution of module elements
This changes the `decl_ctx` to be toplevel only, with flattened references to
uids for most elements. The module hierarchy, which is still useful in a few
places, is kept separately.

Module names are also changed to UIDs early on, and support for module aliases
has been added (needs testing).

This resolves some issues with lookup, and should be much more robust, as well
as more convenient for most lookups.

The `decl_ctx` was also extended for string ident lookups, which avoids having
to keep the desugared resolution structure available throughout the compilation
chain.
2023-11-30 21:14:12 +01:00
Louis Gesbert
326ee07f5d Interpreter: handle lcalc with exceptions 2023-11-28 15:02:11 +01:00
Louis Gesbert
4e465d2b48 Printer: some small improvements 2023-11-28 13:37:46 +01:00
Louis Gesbert
447f6d41f1 Interpreter: fix execution with closure_conversion
and context variables
2023-11-28 13:37:46 +01:00
Louis Gesbert
80475ad5ef Printer: show toplevel uids in debug mode
otherwise we had an inconsistency between what's defined at toplevel and what
appears in expressions.
2023-11-28 11:15:01 +01:00
adelaett
a734413d39 typing default: fix ocaml runtime when using eoption 2023-11-27 11:17:38 +01:00
adelaett
324ca74053 typed defaults: fixed interpreter value initialization in lcalc mode
when having the avoid_exceptions flag enabled.
2023-11-27 11:12:35 +01:00
adelaett
cb29fdeefe fixing the handle_opt in the interpreter. 2023-11-27 11:09:08 +01:00
adelaett
4a5335162e Typed default: implementing the type for handle defaults, as well as the
compile without exceptions compilation pass, using the newly found
invariant
2023-11-27 11:09:08 +01:00
Louis Gesbert
cc4e5339dd Typed defaults: small simplification and fixes 2023-11-27 11:09:08 +01:00
Louis Gesbert
1efda5ca22 Typing defaults: support nested priorities
The way nested priorities are encoded use `< < excs | true :- nested > :- x >`,
which imply that `nested` can actually be ∅ ; to cope with this, the typing of
default terms is made more generic (the return type is now the same as the
`cons` type `'a`, rather than `<'a>`). For the general case, we add an explicit
`EPureDefault` node which just encapsulates its argument (a `return`, in monad
terminology).
2023-11-27 11:09:08 +01:00
Louis Gesbert
c4715ea86e Reformat 2023-11-27 11:09:08 +01:00
Louis Gesbert
bcf285913e Typing the HandleDefault operator 2023-11-27 11:06:33 +01:00
Louis Gesbert
fd50e6186f Fix default typing across modules 2023-11-27 11:06:33 +01:00
Louis Gesbert
958aaebac3 Typing defaults fixes: keep in and out type in scope sigs 2023-11-27 11:06:16 +01:00
Louis Gesbert
0be2636e65 Typing defaults: making the compiler adhere to the new type discipline 2023-11-27 11:06:01 +01:00
Louis Gesbert
b98bad8c33 Add a --no-typing option
it is useful e.g. to be able to print intermediate ASTs when they don't type, to
debug the typing errors. This is better than commenting the typing line each
time.

Note that the option is not available on all targets (esp. not for ocaml and
python outputs ; it's allowed on the interpreters for debugging purposes but I'm
not sure if that's a good idea)
2023-11-27 11:06:01 +01:00
Louis Gesbert
9425753eca Typer: add built-in "'a default" type 2023-11-27 11:06:01 +01:00
Louis Gesbert
e2730c0b44 Avoid redundant position in type error 2023-11-27 11:05:58 +01:00
Louis Gesbert
4fa9326618 Typer: on error, print the expression being typed in debug mode
useful when typing fails on internally generated expressions
2023-11-27 11:03:47 +01:00
Denis Merigoux
c46f5d568d
Don't put a box in list printing but do indent (#524)
Don't put a box in list printing but do indent
2023-11-02 11:56:57 +01:00
Louis Gesbert
1d8e3748ea Improving the printer on arrays 2023-11-02 11:12:51 +01:00
Louis Gesbert
73df41eb6f
More complete tests on module calls and a bunch of fixes (#525) 2023-10-17 09:42:48 +02:00
Louis Gesbert
bd90555e96 The interpreter might return custom terms
since scope outputs may contain functions this shouldn't be excluded; functions
from the interpreter now reflect this
2023-10-13 16:16:45 +02:00
Louis Gesbert
3b0e576a24 Fix module name propagation 2023-10-13 16:13:02 +02:00
Louis Gesbert
61ec34e3d9 Fix handling of context vars with all call cases 2023-10-12 14:47:43 +02:00
Louis Gesbert
f8b6e60e16 Fix handling of context variables in the interpreter 2023-10-12 14:42:57 +02:00
Denis Merigoux
9024cf1222
Don't put a box in list printing but do indent 2023-10-12 12:01:28 +02:00
Denis Merigoux
fce192be20
Improve trace printing 2023-10-11 09:37:36 +02:00
Louis Gesbert
8194abaf93 Operator mismatch fix
wow this remained unspotted for some time...
2023-10-03 18:44:12 +02:00
Louis Gesbert
22045a2f06 Tests and fixes on structures across modules 2023-10-03 18:43:14 +02:00
Louis Gesbert
a79acd1fa8 Reformat 2023-09-27 13:19:04 +02:00
Louis Gesbert
ade51234e8 Discard catala option --build-dir that is not useful in the end 2023-09-27 13:18:28 +02:00