mirror of
https://github.com/anoma/juvix.git
synced 2024-12-14 17:32:00 +03:00
2cf3f85439
* work in progress towards implicit arguments * Wip towards implicit types * improve arity checker * Add version of SimpleFungibleToken with implicit arguments * guess arity of body before checking the lhs of a clause * add ArityUnknown and fix some tests * wip: proper errors in arity checker * fix bugs, improve errors and add tests * format * set hlint version to 3.4 in the ci * update pre-commit version to 3.0.0 * minor changes * added more revisions * minor Co-authored-by: Jonathan Cubides <jonathan.cubides@uib.no>
90 lines
1.9 KiB
Plaintext
90 lines
1.9 KiB
Plaintext
module Input;
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Booleans
|
|
--------------------------------------------------------------------------------
|
|
|
|
inductive Bool {
|
|
true : Bool;
|
|
false : Bool;
|
|
};
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Strings
|
|
--------------------------------------------------------------------------------
|
|
|
|
axiom String : Type;
|
|
|
|
compile String {
|
|
ghc ↦ "[Char]";
|
|
c ↦ "char*";
|
|
};
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- IO
|
|
--------------------------------------------------------------------------------
|
|
|
|
axiom Action : Type;
|
|
|
|
compile Action {
|
|
ghc ↦ "IO ()";
|
|
c ↦ "int";
|
|
};
|
|
|
|
foreign c {
|
|
int sequence(int a, int b) {
|
|
return a + b;
|
|
\}
|
|
};
|
|
|
|
infixl 1 >>;
|
|
axiom >> : Action → Action → Action;
|
|
|
|
compile >> {
|
|
ghc ↦ "(>>)";
|
|
c ↦ "sequence";
|
|
};
|
|
|
|
axiom put-str : String → Action;
|
|
|
|
compile put-str {
|
|
ghc ↦ "putStr";
|
|
c ↦ "putStr";
|
|
};
|
|
|
|
axiom put-str-ln : String → Action;
|
|
|
|
compile put-str-ln {
|
|
ghc ↦ "putStrLn";
|
|
c ↦ "putStrLn";
|
|
};
|
|
|
|
bool-to-str : Bool → String;
|
|
bool-to-str true ≔ "True";
|
|
bool-to-str false ≔ "False";
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Pair
|
|
--------------------------------------------------------------------------------
|
|
|
|
inductive Pair (A : Type) (B : Type) {
|
|
mkPair : A → B → Pair A B;
|
|
};
|
|
|
|
fst : {A : Type} → {B : Type} → Pair A B → A;
|
|
fst (mkPair a b) ≔ a;
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Main
|
|
--------------------------------------------------------------------------------
|
|
|
|
fst-of-pair : Action;
|
|
fst-of-pair ≔ (put-str "fst (True, False) = ")
|
|
>> put-str-ln (bool-to-str (fst (mkPair true false)));
|
|
|
|
main : Action;
|
|
main ≔ fst-of-pair;
|
|
|
|
end;
|