I'm following along with the amazing TDDwI, writing a simple removeElem.
Four questions about it:
why can I write 3 declarations for the same pattern?
what's the difference between
absurdandimpossible?in that 3rd case that returns
[],[]is a value, therefore... proof thatxshad anato remove, and did... right?if I remove all 3 of them, the function is still total, and I have an inexplicable tickle that something weird's going on. ?. (i think that's a question)
removeElem : (value : a)
-> (xs : Vect (S n) a)
-> (prf : Elem value xs)
-> Vect n a
removeElem value (value :: ys) Here = ys
removeElem {n = Z} value (y :: []) (There later) = absurd later -- ??
removeElem {n = Z} value (y :: []) (There later) impossible -- ??
removeElem {n = Z} value (y :: []) (There later) = [] -- ??
removeElem {n = (S k)} value (y :: ys) (There later) =
y :: removeElem value ys later