Last active
February 26, 2020 13:09
-
-
Save namenu/5b8c133435b3725218953302f738a06c to your computer and use it in GitHub Desktop.
tdd-idris
This file contains hidden or 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
import Vector | |
-- 8.3 | |
total | |
headUnequal : DecEq a => {xs : Vector n a} -> {ys : Vector n a} -> | |
(contra : (x = y) -> Void) -> ((x::xs) = (y::ys)) -> Void | |
headUnequal contra Refl = contra Refl | |
total | |
tailUnequal : DecEq a => {xs : Vector n a} -> {ys : Vector n a} -> | |
(contra : (xs = ys) -> Void) -> ((x::xs) = (y::ys)) -> Void | |
tailUnequal contra Refl = contra Refl | |
DecEq a => DecEq (Vector n a) where | |
decEq [] [] = Yes Refl | |
decEq (x :: xs) (y :: ys) = | |
case decEq x y of | |
Yes Refl => case decEq xs ys of | |
Yes Refl => Yes Refl | |
No contra => No (tailUnequal contra) | |
No contra => No (headUnequal contra) |
This file contains hidden or 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
module Vector | |
public export | |
data Vector : Nat -> Type -> Type where | |
Nil : Vector Z elem | |
(::) : elem -> Vector len elem -> Vector (S len) elem | |
%name Vector xs, ys, zs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment