2023-04-26 16:26:13 +03:00
|
|
|
{-# unknownPragma: 300 #-}
|
|
|
|
module Pragmas;
|
|
|
|
|
2023-05-17 12:08:48 +03:00
|
|
|
import Stdlib.Prelude open;
|
2023-04-26 16:26:13 +03:00
|
|
|
|
|
|
|
{-# unknownPragma: 0 #-}
|
|
|
|
axiom a : Nat;
|
|
|
|
|
|
|
|
{-#
|
|
|
|
unknownPragma: something
|
|
|
|
unroll: 100
|
|
|
|
inline: false
|
|
|
|
#-}
|
2023-07-11 18:22:07 +03:00
|
|
|
f : Nat → Nat
|
|
|
|
| x := x;
|
2023-04-26 16:26:13 +03:00
|
|
|
|
|
|
|
{-# inline: true #-}
|
2023-07-11 18:22:07 +03:00
|
|
|
g : Nat → Nat
|
|
|
|
| x := suc x;
|
2023-04-26 16:26:13 +03:00
|
|
|
|
|
|
|
{-
|
|
|
|
Multiline highlighting
|
|
|
|
-}
|
|
|
|
--- Judoc comment 1
|
|
|
|
--- Judoc comment 2
|
|
|
|
{-# unroll: 0 #-}
|
|
|
|
terminating
|
2023-07-11 18:22:07 +03:00
|
|
|
h : Nat → Nat
|
|
|
|
| x := x + 5;
|
2023-04-26 16:26:13 +03:00
|
|
|
|
|
|
|
--- Judoc comment
|
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 16:30:11 +03:00
|
|
|
{-# inline: false, unroll: 10, unknownPragma: tratatata #-}
|
2023-07-11 18:22:07 +03:00
|
|
|
main : Nat := 0;
|