1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-02 23:43:01 +03:00
juvix/test
Łukasz Czajka e9284b3ef6
Iterator syntax (#2126)
* Closes #1992 

A function identifier `fun` can be declared as an iterator with
```
syntax iterator fun;
```
For example:
```haskell
syntax iterator for;
for : {A B : Type} -> (A -> B -> A) -> A -> List B -> List A;
for f acc nil := acc;
for f acc (x :: xs) := for (f acc x) xs;
```
Iterator application syntax allows for a finite number of initializers
`acc := a` followed by a finite number of ranges `x in xs`. For example:
```
for (acc := 0) (x in lst) acc + x
```
The number of initializers plus the number of ranges must be non-zero.

An iterator application
```
fun (acc1 := a1; ..; accn := an) (x1 in b1; ..; xk in bk) body
```
gets desugared to
```
fun \{acc1 .. accn x1 .. xk := body} a1 .. an b1 .. bk
```
The `acc1`, ..., `accn`, `x1`, ..., `xk` can be patterns.

The desugaring works on a purely syntactic level. Without further
restrictions, it is not checked if the number of initializers/ranges
matches the type of the identifier. The restrictions on the number of
initializers/ranges can be specified in iterator declaration:
```
syntax iterator fun {init: n, range: k};
syntax iterator for {init: 1, range: 1};
syntax iterator map {init: 0, range: 1};
```
The attributes (`init`, `range`) in between braces are parsed as YAML to
avoid inventing and parsing a new attribute language. Both attributes
are optional.
2023-05-30 15:30:11 +02:00
..
Arity Add juvix global project under xdg directory and other improvements (#1963) 2023-04-13 11:27:39 +02:00
Asm Test numbering (#1977) 2023-04-04 19:29:25 +02:00
BackendGeb VampIR integration (#2103) 2023-05-22 20:18:18 +02:00
Compilation Iterator syntax (#2126) 2023-05-30 15:30:11 +02:00
Core Iterator syntax (#2126) 2023-05-30 15:30:11 +02:00
Examples Add a test suite for milestone examples (#1920) 2023-03-24 13:16:26 +00:00
Formatter Make format command's filepath optional (#2028) 2023-04-27 17:33:08 +02:00
Internal Fix reachability analysis with imports in unreachable nested modules (#2062) 2023-05-12 09:53:30 +01:00
Parsing Add dangling judoc error (#2099) 2023-05-16 15:39:43 +02:00
Reachability Fix ordering of statements in Abstract -> Internal (#2040) 2023-05-15 13:02:09 +02:00
Runtime Test numbering (#1977) 2023-04-04 19:29:25 +02:00
Scope Iterator syntax (#2126) 2023-05-30 15:30:11 +02:00
Termination Add juvix global project under xdg directory and other improvements (#1963) 2023-04-13 11:27:39 +02:00
Typecheck Fix ordering of statements in Abstract -> Internal (#2040) 2023-05-15 13:02:09 +02:00
VampIR VampIR integration (#2103) 2023-05-22 20:18:18 +02:00
Arity.hs Support implicit arguments (#144) 2022-06-13 14:25:22 +02:00
Asm.hs Translation from JuvixAsm to C (#1619) 2022-12-06 11:33:20 +01:00
BackendGeb.hs End-to-end Geb compilation tests (#1942) 2023-03-29 14:02:40 +02:00
Base.hs Add juvix global project under xdg directory and other improvements (#1963) 2023-04-13 11:27:39 +02:00
Compilation.hs Pattern matching compilation (#1874) 2023-03-27 10:42:27 +02:00
Core.hs Implement core transformation let-hoisting (#2076) 2023-05-16 13:42:44 +02:00
Examples.hs Add a test suite for milestone examples (#1920) 2023-03-24 13:16:26 +00:00
Format.hs Make format command's filepath optional (#2028) 2023-04-27 17:33:08 +02:00
Formatter.hs Add juvix format command (#1886) 2023-03-29 15:51:04 +02:00
Internal.hs Add translation from Internal to Core (#1567) 2022-11-07 14:47:56 +01:00
Main.hs VampIR integration (#2103) 2023-05-22 20:18:18 +02:00
Parsing.hs Disallow tab characters as spaces (#1523) 2022-09-07 13:59:41 +02:00
Reachability.hs Compute name dependency graph and filter unreachable definitions (#1408) 2022-07-25 18:38:44 +02:00
Runtime.hs Juvix C runtime (#1580) 2022-11-03 09:38:09 +01:00
Scope.hs [ CI ] New jobs: ormolu and hlint 2022-04-05 19:57:21 +02:00
Termination.hs Add the termination checker to the pipeline (#111) 2022-05-30 13:40:52 +02:00
Typecheck.hs Add lambda expressions to internal and add typechecking support (#1538) 2022-09-23 15:43:18 +02:00
VampIR.hs VampIR integration (#2103) 2023-05-22 20:18:18 +02:00