1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-14 17:32:00 +03:00
juvix/tests/positive/MiniC/ClosureEnv/Input.juvix

109 lines
2.1 KiB
Plaintext

module Input;
open import Data.IO;
open import Data.String;
axiom Int : Type;
compile Int {
c ↦ "int";
};
axiom Int_0 : Int;
compile Int_0 {
c ↦ "0";
};
axiom Int_1 : Int;
compile Int_1 {
c ↦ "1";
};
axiom to-str : Int → String;
compile to-str {
c ↦ "intToStr";
};
foreign c {
int cplus(int l, int r) {
return l + r;
\}
};
axiom plus : Int → Int → Int;
compile plus {
c ↦ "cplus";
};
inductive Nat {
zero : Nat;
suc : Nat → Nat;
};
nplus : Nat → Nat → Nat;
nplus zero n ≔ n;
nplus (suc m) n ≔ suc (nplus m n);
nplus-to-int : Nat → Int;
nplus-to-int zero ≔ Int_0;
nplus-to-int (suc n) ≔ plus Int_1 (nplus-to-int n);
nOne : Nat;
nOne ≔ suc zero;
nplusOne : Nat → Nat → Nat;
nplusOne n ≔ nplus nOne;
plusOneInt : Int → Int;
plusOneInt ≔ plus Int_1;
one : Int;
one ≔ Int_1;
two : Int;
two ≔ plusOneInt one;
three : Int;
three ≔ plusOneInt two;
plusXIgnore2 : Int → Int → Int → Int → Int;
plusXIgnore2 _ _ ≔ plus;
plusXIgnore : Int → Int → Int → Int;
plusXIgnore _ ≔ plus;
plusXIgnore22 : Int → Int → Int → Int → Int;
plusXIgnore22 _ ≔ plusXIgnore;
plusX : Int → Int → Int;
plusX ≔ plus;
plusXThree : Int → Int;
plusXThree ≔ plusX three;
plusOne : Int → Int;
plusOne ≔ plus one;
plusOneThenTwo : Int;
plusOneThenTwo ≔ plusOne two;
plusOneThenX : Int → Int;
plusOneThenX x ≔ plusOne x;
plusOneTwo : Int;
plusOneTwo ≔ plus one two;
main : Action;
main ≔ put-str "plusOne one: " >> put-str-ln (to-str (plusOne one))
>> put-str "plusOneThenTwo: " >> put-str-ln (to-str (plusOneThenTwo))
>> put-str "plusOneThenX three: " >> put-str-ln (to-str (plusOneThenX three))
>> put-str "plusOneTwo: " >> put-str-ln (to-str (plusOneTwo))
>> put-str "plusX three three: " >> put-str-ln (to-str (plusX three three))
>> put-str "plusXIgnore one three three: " >> put-str-ln (to-str (plusXIgnore one three three))
>> put-str "plusXIgnore2 one one three three: " >> put-str-ln (to-str (plusXIgnore2 one one three three))
>> put-str "plusXIgnore22 one one three two: " >> put-str-ln (to-str (plusXIgnore22 one one three two))
end;