2022-03-30 17:03:56 +03:00
|
|
|
|
module HelloWorld;
|
|
|
|
|
|
|
|
|
|
inductive ℕ {
|
|
|
|
|
zero : ℕ;
|
|
|
|
|
suc : ℕ → ℕ;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
inductive V {
|
|
|
|
|
zeroV : V;
|
|
|
|
|
sucV : V;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
infixl 6 +;
|
|
|
|
|
+ : ℕ → ℕ → ℕ;
|
2022-09-30 03:55:32 +03:00
|
|
|
|
+ zero b := b;
|
|
|
|
|
+ (suc a) b := suc (a + b);
|
2022-03-30 17:03:56 +03:00
|
|
|
|
|
|
|
|
|
infixl 7 *;
|
|
|
|
|
* : ℕ → ℕ → ℕ;
|
2022-09-30 03:55:32 +03:00
|
|
|
|
* zero b := zero;
|
|
|
|
|
* (suc a) b := b + (a * b);
|
2022-03-30 17:03:56 +03:00
|
|
|
|
|
2022-04-28 18:42:15 +03:00
|
|
|
|
axiom Action : Type;
|
|
|
|
|
compile Action {
|
2022-03-30 17:03:56 +03:00
|
|
|
|
ghc ↦ "IO ()";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
infixl 1 >>;
|
2022-04-28 18:42:15 +03:00
|
|
|
|
axiom >> : Action → Action → Action;
|
|
|
|
|
compile >> {
|
2022-03-30 17:03:56 +03:00
|
|
|
|
ghc ↦ "(>>)";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
axiom String : Type;
|
|
|
|
|
|
2022-04-28 18:42:15 +03:00
|
|
|
|
axiom putStr : String → Action;
|
|
|
|
|
compile putStr {
|
2022-03-30 17:03:56 +03:00
|
|
|
|
ghc ↦ "putStrLn";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
doTimes : ℕ → Action → Action;
|
2022-09-30 03:55:32 +03:00
|
|
|
|
doTimes zero _ := putStr "done";
|
|
|
|
|
doTimes (suc n) a := a >> doTimes n a;
|
2022-03-30 17:03:56 +03:00
|
|
|
|
|
|
|
|
|
three : ℕ;
|
2022-09-30 03:55:32 +03:00
|
|
|
|
three := suc (suc (suc zero));
|
2022-03-30 17:03:56 +03:00
|
|
|
|
|
|
|
|
|
main : Action;
|
|
|
|
|
main := doTimes three (putStr "hello world");
|
|
|
|
|
|
|
|
|
|
end;
|