5||| A proof that some element is found in a list.
7||| Example: `the (Elem "bar" ["foo", "bar", "baz"]) (tactics { search })`
8data Elem : a -> List a -> Type where
9 ||| A proof that the element is at the front of the list.
11 ||| Example: `the (Elem "a" ["a", "b"]) Here`
12 Here : Elem x (x :: xs)
13 ||| A proof that the element is after the front of the list
15 ||| Example: `the (Elem "b" ["a", "b"]) (There Here)`
16 There : Elem x xs -> Elem x (y :: xs)
18instance Uninhabited (Elem {a} x []) where
19 uninhabited Here impossible
20 uninhabited (There p) impossible
22||| Is the given element a member of the given list.
24||| @x The element to be tested.
25||| @xs The list to be checked against
26isElem : DecEq a => (x : a) -> (xs : List a) -> Dec (Elem x xs)
27isElem x [] = No absurd
28isElem x (y :: xs) with (decEq x y)
29 isElem x (x :: xs) | (Yes Refl) = Yes Here
30 isElem x (y :: xs) | (No contra) with (isElem x xs)
31 isElem x (y :: xs) | (No contra) | (Yes prf) = Yes (There prf)
32 isElem x (y :: xs) | (No contra) | (No f) = No (mkNo contra f)
34 mkNo : {xs' : List a} ->
35 ((x' = y') -> Void) -> (Elem x' xs' -> Void) ->
36 Elem x' (y' :: xs') -> Void
37 mkNo f g Here = f Refl
38 mkNo f g (There x) = g x
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list