mirror of
https://github.com/anoma/juvix.git
synced 2024-12-15 18:13:56 +03:00
50 lines
717 B
Plaintext
50 lines
717 B
Plaintext
|
module HelloWorld;
|
|||
|
|
|||
|
inductive ℕ {
|
|||
|
zero : ℕ;
|
|||
|
suc : ℕ → ℕ;
|
|||
|
};
|
|||
|
|
|||
|
inductive V {
|
|||
|
zeroV : V;
|
|||
|
sucV : V;
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
infixl 6 +;
|
|||
|
+ : ℕ → ℕ → ℕ;
|
|||
|
+ zero b ≔ b;
|
|||
|
+ (suc a) b ≔ suc (a + b);
|
|||
|
|
|||
|
infixl 7 *;
|
|||
|
* : ℕ → ℕ → ℕ;
|
|||
|
* zero b ≔ zero;
|
|||
|
* (suc a) b ≔ b + (a * b);
|
|||
|
|
|||
|
axiom Action : Type {
|
|||
|
ghc ↦ "IO ()";
|
|||
|
};
|
|||
|
|
|||
|
infixl 1 >>;
|
|||
|
axiom >> : Action → Action → Action {
|
|||
|
ghc ↦ "(>>)";
|
|||
|
};
|
|||
|
|
|||
|
axiom String : Type;
|
|||
|
|
|||
|
axiom putStr : String → Action {
|
|||
|
ghc ↦ "putStrLn";
|
|||
|
};
|
|||
|
|
|||
|
doTimes : ℕ → Action → Action;
|
|||
|
doTimes zero _ ≔ putStr "done";
|
|||
|
doTimes (suc n) a ≔ a >> doTimes n a;
|
|||
|
|
|||
|
three : ℕ;
|
|||
|
three ≔ suc (suc (suc zero));
|
|||
|
|
|||
|
main : Action;
|
|||
|
main := doTimes three (putStr "hello world");
|
|||
|
|
|||
|
end;
|