mirror of
https://github.com/anoma/juvix.git
synced 2024-12-15 01:52:11 +03:00
8daca2ba0a
- Closes #2330 - Closes #2329 This pr implements the syntax changes described in #2330. It drops support for the old yaml-based syntax. Some valid examples: ``` syntax iterator for {init := 1; range := 1}; syntax fixity cons := binary {assoc := right}; syntax fixity cmp := binary; syntax fixity cmp := binary {}; -- debatable whether we want to accept empty {} or not. I think we should ``` # Future work This pr creates an asymmetry between iterators and operators definitions. Iterators definition do not require a constructor. We could add it to make it homogeneous, but it looks a bit redundant: ``` syntax iterator for := mkIterator {init := 1; range := 1}; ``` We could consider merging iterator and fixity declarations with this alternative syntax. ``` syntax XXX for := iterator {init := 1; range := 1}; syntax XXX cons := binary {assoc := right}; ``` where `XXX` is a common keyword. Suggestion by @lukaszcz XXX = declare --------- Co-authored-by: Łukasz Czajka <62751+lukaszcz@users.noreply.github.com> Co-authored-by: Lukasz Czajka <lukasz@heliax.dev>
28 lines
570 B
Plaintext
28 lines
570 B
Plaintext
module Iterators;
|
|
|
|
syntax iterator for {init := 1; range := 1};
|
|
|
|
for {A B : Type} (f : A → B → A) (x : A) (y : B) : A :=
|
|
f x y;
|
|
|
|
syntax iterator itconst {init := 2; range := 2};
|
|
|
|
itconst
|
|
: {A B C : Type} → (A → A → B → C → A) → A → A → B → C → A
|
|
| f := f;
|
|
|
|
builtin bool
|
|
type Bool :=
|
|
| true : Bool
|
|
| false : Bool;
|
|
|
|
main : Bool :=
|
|
let
|
|
z : Bool := false;
|
|
in itconst (a := true; b := false) (c in false; d in false)
|
|
for (x := true) (y in false)
|
|
case x of {
|
|
| true := y
|
|
| false := z
|
|
};
|