1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 01:52:11 +03:00
juvix/tests/positive/MicroJuvix/Simple.mjuvix

45 lines
694 B
Plaintext
Raw Normal View History

module Simple;
inductive T {
tt : T;
};
someT : T;
someT ≔ tt;
inductive Bool {
false : Bool;
true : Bool;
};
inductive Nat {
zero : Nat;
suc : Nat → Nat;
};
infix 3 ==;
== : Nat → Nat → Bool;
== zero zero ≔ true;
== (suc a) (suc b) ≔ a == b;
== _ _ ≔ false;
infixl 4 +;
+ : Nat → Nat → Nat;
+ zero b ≔ b;
+ (suc a) b ≔ suc (a + b);
infixr 5 ∷;
inductive List {
nil : List;
∷ : Nat → List → List;
};
foldr : (Nat → Nat → Nat) → Nat → List → Nat;
foldr _ v nil ≔ v;
foldr f v (a ∷ as) ≔ f a (foldr f v as);
sum : List → Nat;
sum ≔ foldr (+) zero;
2022-04-04 18:44:08 +03:00
end;