mirror of
https://github.com/HigherOrderCO/Kind.git
synced 2024-10-05 19:27:30 +03:00
add missing files
This commit is contained in:
parent
7c09ed7b4e
commit
9a7a3aa1aa
6
book/Char.is_blank.kind2
Normal file
6
book/Char.is_blank.kind2
Normal file
@ -0,0 +1,6 @@
|
||||
Char.is_blank
|
||||
: ∀(a: Char)
|
||||
Bool
|
||||
= λa (Bool.or
|
||||
(Char.equal a #10) // newline
|
||||
(Char.equal a #32)) // space
|
4
book/Char.is_newline.kind2
Normal file
4
book/Char.is_newline.kind2
Normal file
@ -0,0 +1,4 @@
|
||||
Char.is_newline
|
||||
: ∀(a: Char)
|
||||
Bool
|
||||
= λa (Char.equal a #10) // newline
|
5
book/Char.is_slash.kind2
Normal file
5
book/Char.is_slash.kind2
Normal file
@ -0,0 +1,5 @@
|
||||
Char.is_slash
|
||||
: ∀(a: Char)
|
||||
Bool
|
||||
= λa (Char.equal a #47) // slash
|
||||
|
@ -1629,6 +1629,18 @@ Kind.compile.hvm.term
|
||||
= λterm λdep
|
||||
(String.Concatenator.build (Kind.compile.hvm.term.go term dep))
|
||||
|
||||
// TODO: implement Kind.compile.hvm.book
|
||||
|
||||
```haskell
|
||||
Kind.compile.hvm.book
|
||||
: ∀(book: Kind.Book)
|
||||
String
|
||||
= λbook
|
||||
let P = λx String
|
||||
let fold = λkey λval λacc (String.concat acc (String.concat key (String.concat " = " (String.concat (Kind.compile.hvm.term val Nat.zero) "\n"))))
|
||||
(String.Map.fold Kind.Term fold book "")
|
||||
```
|
||||
|
||||
// Tests
|
||||
// -----
|
||||
|
||||
|
42
book/List.Map.kind2
Normal file
42
book/List.Map.kind2
Normal file
@ -0,0 +1,42 @@
|
||||
List.Map
|
||||
: ∀(K: *)
|
||||
∀(V: *)
|
||||
*
|
||||
= λK λV
|
||||
(List (Pair K V))
|
||||
|
||||
List.Map.get
|
||||
: ∀(K: *)
|
||||
∀(V: *)
|
||||
∀(eql: ∀(a: K) ∀(b: K) Bool)
|
||||
∀(key: K)
|
||||
∀(map: (List.Map K V))
|
||||
(Maybe V)
|
||||
= λK λV λeql λkey λmap
|
||||
let P = λx(Maybe V)
|
||||
let cons = λhead λtail
|
||||
let P = λx(Maybe V)
|
||||
let new = λhead.fst λhead.snd
|
||||
let P = λx(Maybe V)
|
||||
let true = (Maybe.some V head.snd)
|
||||
let false = (List.Map.get K V eql key tail)
|
||||
(~(eql head.fst key) P true false)
|
||||
(~head P new)
|
||||
let nil = (Maybe.none V)
|
||||
(~map P cons nil)
|
||||
|
||||
List.Map.set
|
||||
: ∀(K: *)
|
||||
∀(V: *)
|
||||
∀(key: K)
|
||||
∀(val: V)
|
||||
∀(map: (List.Map K V))
|
||||
(List.Map K V)
|
||||
= λK λV λkey λval λmap
|
||||
(List.cons (Pair K V) (Pair.new K V key val) map)
|
||||
|
||||
List.Map.new
|
||||
: ∀(K: *)
|
||||
∀(V: *)
|
||||
(List.Map K V)
|
||||
= λK λV (List.nil (Pair K V))
|
27
book/String.Map.kind2
Normal file
27
book/String.Map.kind2
Normal file
@ -0,0 +1,27 @@
|
||||
// Temporarily just a list of key/val
|
||||
|
||||
String.Map
|
||||
: ∀(A: *) *
|
||||
= (List.Map String)
|
||||
|
||||
String.Map.get
|
||||
: ∀(A: *)
|
||||
∀(key: String)
|
||||
∀(map: (String.Map A))
|
||||
(Maybe A)
|
||||
= λA λkey λmap
|
||||
(List.Map.get String A String.equal key map)
|
||||
|
||||
String.Map.set
|
||||
: ∀(A: *)
|
||||
∀(key: String)
|
||||
∀(val: A)
|
||||
∀(map: (String.Map A))
|
||||
(String.Map A)
|
||||
= λA λkey λval λmap
|
||||
(List.Map.set String A key val map)
|
||||
|
||||
String.Map.new
|
||||
: ∀(V: *)
|
||||
(String.Map V)
|
||||
= λV (String.Map.new String V)
|
27
book/U60.Map.kind2
Normal file
27
book/U60.Map.kind2
Normal file
@ -0,0 +1,27 @@
|
||||
// Temporarily just a list of key/val
|
||||
|
||||
U60.Map
|
||||
: ∀(A: *) *
|
||||
= (List.Map #U60)
|
||||
|
||||
U60.Map.get
|
||||
: ∀(A: *)
|
||||
∀(key: #U60)
|
||||
∀(map: (U60.Map A))
|
||||
(Maybe A)
|
||||
= λA λkey λmap
|
||||
(List.Map.get #U60 A U60.equal key map)
|
||||
|
||||
U60.Map.set
|
||||
: ∀(A: *)
|
||||
∀(key: #U60)
|
||||
∀(val: A)
|
||||
∀(map: (U60.Map A))
|
||||
(U60.Map A)
|
||||
= λA λkey λval λmap
|
||||
(List.Map.set #U60 A key val map)
|
||||
|
||||
U60.Map.new
|
||||
: ∀(V: *)
|
||||
(String.Map V)
|
||||
= λV (String.Map.new String V)
|
8
book/U60.from_nat.kind2
Normal file
8
book/U60.from_nat.kind2
Normal file
@ -0,0 +1,8 @@
|
||||
U60.from_nat
|
||||
: ∀(n: Nat)
|
||||
#U60
|
||||
= λn
|
||||
let P = λx(#U60)
|
||||
let succ = λn.pred #(+ #1 (U60.from_nat n.pred))
|
||||
let zero = #0
|
||||
(~n P succ zero)
|
50
book/test5.kind2
Normal file
50
book/test5.kind2
Normal file
@ -0,0 +1,50 @@
|
||||
test5
|
||||
: ∀(x: Bool)
|
||||
(Equal Bool (Bool.not (Bool.not x)) x)
|
||||
= λb
|
||||
(~b ?A ?T ?F)
|
||||
|
||||
|
||||
//test5
|
||||
//: (List Bool)
|
||||
//= (List.cons ?A Bool.true
|
||||
//(List.cons ?B Bool.true
|
||||
//(List.cons ?C Bool.true
|
||||
//(List.nil ?D))))
|
||||
|
||||
// ?S : (?P true) = (?P (F true))
|
||||
// ?Z : (?P false) = (?P (F false))
|
||||
// ?R : (?P b) = (P (f b))
|
||||
|
||||
// ----------------------------------
|
||||
|
||||
//IsZero
|
||||
//: ∀(n: Nat)
|
||||
//*
|
||||
//= λn
|
||||
//∀(P: ∀(n: Nat) ∀(x: (IsZero n)) *)
|
||||
//∀(y: (P Nat.zero IsZero.y))
|
||||
//(P n self)
|
||||
|
||||
//F
|
||||
//: ∀(n: Nat)
|
||||
//∀(e: IsZero (pred n))
|
||||
//(F n e)
|
||||
//= (~e ?P ?B)
|
||||
|
||||
|
||||
//?B : (?P Z Yep)
|
||||
//?R : (?P (pred n) e ) = (F n e)
|
||||
|
||||
|
||||
|
||||
|
||||
//?T : (?H True)
|
||||
//?F : (?H False)
|
||||
//RT : (?H x) = (Vector Nat (if x 1 else 0))
|
||||
|
||||
|
||||
//Unif
|
||||
//: ∀(b: Bool)
|
||||
//(Foo b)
|
||||
//= λb (~b ?P Bool.true Bool.false)
|
5
book/test6.kind2
Normal file
5
book/test6.kind2
Normal file
@ -0,0 +1,5 @@
|
||||
test6
|
||||
: Nat
|
||||
= (Nat.succ (Nat.succ (Nat.succ Nat.zero)))
|
||||
|
||||
|
@ -412,8 +412,8 @@
|
||||
|
||||
(Normalizer (Ref nam val)) = (Normalizer val)
|
||||
(Normalizer (Ann val typ)) = (Normalizer val)
|
||||
//(Normalizer val) = (Read (Compile val)) // compiles to native and reads as string
|
||||
(Normalizer val) = ((Compile val)) // compiles to native and show it
|
||||
(Normalizer val) = (Read (Compile val)) // compiles to native and reads as string
|
||||
//(Normalizer val) = ((Compile val)) // compiles to native and show it
|
||||
//(Normalizer val) = (Normal 1 val 1) // uses the normalizer function
|
||||
|
||||
(Checker (Ref nam val)) = (Checker val)
|
||||
|
Loading…
Reference in New Issue
Block a user