-
-
Save edwinb/029dd3e8e78855e47110fd6f9d27f696 to your computer and use it in GitHub Desktop.
TinyIdris vectors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Nat : Type where | |
Z : Nat | |
S : Nat -> Nat | |
plus : Nat -> Nat -> Nat | |
pat y : Nat => | |
plus Z y = y | |
pat k : Nat, y : Nat => | |
plus (S k) y = S (plus k y) | |
data Vect : Nat -> Type -> Type where | |
Nil : (a : Type) -> Vect Z a | |
Cons : (a : Type) -> (k : Nat) -> | |
a -> Vect k a -> Vect (S k) a | |
append : (a : Type) -> (n : Nat) -> (m : Nat) -> | |
Vect n a -> Vect m a -> Vect (plus n m) a | |
pat a : Type, k : Nat, ys : Vect k a => | |
append a Z k (Nil a) ys = ys | |
pat a : Type, n : Nat, x : a, xs : Vect n a, k : Nat, ys : Vect k a => | |
append a (S n) k (Cons a n x xs) ys | |
= Cons a (plus n k) x (append a n k xs ys) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment