1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-03 09:41:10 +03:00
juvix/tests
Jan Mas Rovira 2d666fd82c
Named arguments (#2250)
- closes #1991 

This pr implements named arguments as described in #1991. It does not
yet implement optional arguments, which should be added in a later pr as
they are not required for record syntax.

# Syntax Overview

Named arguments are a convenient mehcanism to provide arguments, where
we give the arguments by name instead of by position. Anything with a
type signature can have named arguments, i.e. functions, types,
constructors and axioms.

For instance, if we have (note that named arguments can also appear on
the rhs of the `:`):
```
fun : {A B : Type} (f : A -> B) : (x : A) -> B := ... ;
```
With the traditional positional application, we would write
```
fun suc zero
```
With named arguments we can write the following:
1. `fun (f := suc) (x := zero)`.
2. We can change the order: `fun (x := zero) (f := suc)`.
3. We can group the arguments: `fun (x := zero; f := suc)`.
4. We can partially apply functions with named arguments: `fun (f :=
suc) zero`.
5. We can provide implicit arguments analogously (with braces): `fun {A
:= Nat; B := Nat} (f := suc; x := zero)`.
6. We can skip implicit arguments: `fun {B := Nat} (f := suc; x :=
zero)`.

What we cannot do:
1. Skip explicit arguments. E.g. `fun (x := zero)`.
2. Mix explicit and implicit arguments in the same group. E.g. `fun (A
:= Nat; f := suc)`
3. Provide explicit and implicit arguments in different order. E.g. `fun
(f := suc; x := zero) {A := Nat}`.
2023-07-18 10:32:34 +01:00
..
Asm New compilation pipeline (#1832) 2023-03-14 16:24:07 +01:00
benchmark Fix runtime C maybe benchmark example (#2195) 2023-06-16 09:54:13 +01:00
Compilation New syntax for function definitions (#2243) 2023-07-10 19:57:55 +02:00
Core Fold lets when the bound variable occurs at most once (#2231) 2023-06-29 13:02:10 +02:00
examplesExpected Add a test suite for milestone examples (#1920) 2023-03-24 13:16:26 +00:00
Geb/positive Update to GEB version 0.3.2 (#2244) 2023-07-11 11:02:48 +02:00
Internal Fix reachability analysis with imports in unreachable nested modules (#2062) 2023-05-12 09:53:30 +01:00
negative Named arguments (#2250) 2023-07-18 10:32:34 +01:00
positive Named arguments (#2250) 2023-07-18 10:32:34 +01:00
runtime/positive Respect fixity in runtime printer (#2182) 2023-06-07 11:44:41 +02:00
smoke/Commands Update to GEB version 0.3.2 (#2244) 2023-07-11 11:02:48 +02:00
VampIR The public pragma (#2223) 2023-06-22 18:31:53 +02:00
.gitattributes Juvix C runtime (#1580) 2022-11-03 09:38:09 +01:00