2 | module Data.List.Lazy.Quantifiers
5 | import Data.List.Lazy
15 | data Any : (p : a -> Type) -> (xs : LazyList a) -> Type where
16 | Here : {0 xs : Lazy (LazyList a)} -> p x -> Any p (x :: xs)
17 | There : {0 xs : Lazy (LazyList a)} -> Any p xs -> Any p (x :: xs)
20 | toExists : Any p xs -> Exists p
21 | toExists (Here prf) = Evidence _ prf
22 | toExists (There p) = toExists p
25 | toDPair : {xs : LazyList a} -> Any p xs -> DPair a p
26 | toDPair (Here prf) = (
_ ** prf)
27 | toDPair (There p) = toDPair p
30 | Uninhabited (Any p Nil) where
31 | uninhabited (Here
_) impossible
32 | uninhabited (There
_) impossible
35 | {0 p : a -> Type} -> Uninhabited (p x) => Uninhabited (Any p xs) => Uninhabited (Any p $
x::xs) where
36 | uninhabited (Here y) = uninhabited y
37 | uninhabited (There y) = uninhabited y
41 | mapProperty : (f : {0 x : a} -> p x -> q x) -> Any p l -> Any q l
42 | mapProperty f (Here p) = Here (f p)
43 | mapProperty f (There p) = There (mapProperty f p)
52 | any : (dec : (x : a) -> Dec (p x)) -> (xs : LazyList a) -> Dec (Any p xs)
53 | any _ Nil = No uninhabited
54 | any p (x::xs) with (p x)
55 | any p (x::xs) | Yes prf = Yes (Here prf)
56 | any p (x::xs) | No ctra =
58 | Yes prf' => Yes (There prf')
59 | No ctra' => No $
\case
61 | There pxs => ctra' pxs
64 | pushOut : Functor p => Any (p . q) xs -> p $
Any q xs
65 | pushOut @{fp} (Here v) = map @{fp} Here v
66 | pushOut @{fp} (There n) = map @{fp} There $
pushOut n