mirror of
https://github.com/anoma/juvix.git
synced 2024-11-23 08:18:43 +03:00
[stdlib] add MiniJuvix standard library as a submodule
This commit is contained in:
parent
aea7208d88
commit
c369eb6fa0
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "minijuvix-stdlib"]
|
||||
path = minijuvix-stdlib
|
||||
url = git@github.com:heliaxdev/minijuvix-stdlib.git
|
@ -1,116 +0,0 @@
|
||||
module Prelude;
|
||||
module Bools;
|
||||
inductive Bool {
|
||||
true : Bool;
|
||||
false : Bool;
|
||||
};
|
||||
end;
|
||||
|
||||
module Ord;
|
||||
inductive Ordering {
|
||||
LT : Ordering;
|
||||
EQ : Ordering;
|
||||
GT : Ordering;
|
||||
};
|
||||
end;
|
||||
|
||||
module Nat;
|
||||
inductive ℕ {
|
||||
zero : ℕ;
|
||||
suc : ℕ → ℕ;
|
||||
};
|
||||
|
||||
open Bools;
|
||||
open Ord;
|
||||
|
||||
compare : ℕ → ℕ → ℕ;
|
||||
compare zero zero ≔ EQ;
|
||||
compare zero _ ≔ LT;
|
||||
compare (suc _) zero ≔ GT;
|
||||
compare (suc a) (suc b) ≔ compare a b;
|
||||
|
||||
infix 4 ==;
|
||||
== : ℕ → ℕ → ℕ;
|
||||
== a b ≔ match compare a b {
|
||||
Eq ↦ true;
|
||||
_ ↦ false;
|
||||
};
|
||||
|
||||
end;
|
||||
|
||||
module List;
|
||||
open Bools;
|
||||
|
||||
infixr 5 ∷;
|
||||
inductive List (a : Type) {
|
||||
nil : List a;
|
||||
∷ : a → List a → List a;
|
||||
};
|
||||
|
||||
foldr : (a : Type) → (b : Type) → (a → b → b) → b → List a → b;
|
||||
foldr _ _ _ z nil ≔ z;
|
||||
foldr _ _ f z (h ∷ hs) ≔ f h (foldr f z hs);
|
||||
|
||||
foldl : (a : Type) → (b : Type) → (b → a → b) → b → List a → b;
|
||||
foldl a b f z nil ≔ z ;
|
||||
foldl a b f z (h ∷ hs) ≔ foldl a b f (f z h) hs;
|
||||
|
||||
map : (a : Type) → (b : Type) → (a → b) → b → List a → b;
|
||||
map _ _ f nil ≔ nil;
|
||||
map a b f (h ∷ hs) ≔ f h ∷ (map a b f hs);
|
||||
|
||||
filter : (a : Type) → (a → Bool) → List a → List a;
|
||||
filter _ f nil ≔ nil;
|
||||
filter a f (h ∷ hs) ≔ match f h {
|
||||
true ↦ h ∷ filter a f hs;
|
||||
true ↦ filter a f hs;
|
||||
};
|
||||
open Ord;
|
||||
|
||||
compare : (a : Type) → (a → a → Ordering) → List a → List a → Ordering;
|
||||
compare _ _ nil nil ≔ EQ;
|
||||
compare _ _ nil (_ ∷ _) ≔ LT;
|
||||
compare _ _ (_ ∷ _) nil ≔ GT;
|
||||
compare a cmp (x ∷ xs) (y ∷ ys) ≔ match cmp x y {
|
||||
EQ ↦ compare a cmp xs ys;
|
||||
LT ↦ LT;
|
||||
GT ↦ GT;
|
||||
};
|
||||
|
||||
infixr 5 ++;
|
||||
++ : (a : Type) → List a → List a → List a;
|
||||
++ a nil ys ≔ ys;
|
||||
++ a (x ∷ xs) ys ≔ x ∷ (xs ++ ys);
|
||||
|
||||
end;
|
||||
|
||||
module Character;
|
||||
open Nat;
|
||||
Char : Type;
|
||||
Char ≔ ℕ;
|
||||
end;
|
||||
|
||||
module Strings;
|
||||
open List hiding {compare};
|
||||
open Character;
|
||||
open Ord;
|
||||
|
||||
String : Type;
|
||||
String ≔ List Char;
|
||||
|
||||
compare : String → String → Ordering;
|
||||
compare s1 s2 ≔ List.compare String Nat.compare;
|
||||
end;
|
||||
|
||||
module StringSets;
|
||||
open Strings public;
|
||||
open List;
|
||||
|
||||
StringSet : Type;
|
||||
StringSet ≔ List String;
|
||||
end;
|
||||
|
||||
open Strings hiding {compare} public;
|
||||
open Nat public;
|
||||
open Bools public;
|
||||
end;
|
1
minijuvix-stdlib
Submodule
1
minijuvix-stdlib
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit ba5a978895b214c953ddeb81eb6524ce829c9fa2
|
Loading…
Reference in New Issue
Block a user