on master help sign in
Add Uninhabited for Elem x []
commit9ecacca73202a38b2c41becf99d75f638e487da0 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateFri 5 Feb 2016, 14:35 (11 years ago) parent46b5cb6
2 files changed+4−4
libs/base/Data/Vect.idr+4−1 test/effects003/VectMissing.idr−3
libs/base/Data/Vect.idr+4−1
@@ -573,12 +573,15 @@ implementation DecEq a => DecEq (Vect n a) where
573573||| A proof that some element is found in a vector
574574data Elem : a -> Vect k a -> Type where
575575 Here : Elem x (x::xs)
576− There : Elem x xs -> Elem x (y::xs)
576+ There : (prf : Elem x xs) -> Elem x (y::xs)
577577
578578||| Nothing can be in an empty Vect
579579noEmptyElem : {x : a} -> Elem x [] -> Void
580580noEmptyElem Here impossible
581581
582+Uninhabited (Elem x []) where
583+ uninhabited = noEmptyElem
584+
582585||| An item not in the head and not in the tail is not in the Vect at all
583586neitherHereNorThere : {x, y : a} -> {xs : Vect n a} -> Not (x = y) -> Not (Elem x xs) -> Not (Elem x (y :: xs))
584587neitherHereNorThere xneqy xninxs Here = xneqy Refl
test/effects003/VectMissing.idr−3
@@ -3,9 +3,6 @@ module VectMissing
33import Data.Fin
44import Data.Vect
55
6−implementation Uninhabited (Elem x []) where
7− uninhabited Here impossible
8−
96export
107shrink : (xs : Vect (S n) a) -> Elem x xs -> Vect n a
118shrink (x :: ys) Here = ys