0 | module Libraries.Data.List.Thin
2 | import Libraries.Data.NatSet
10 | data Thin : List a -> List a -> Type where
12 | Drop : Thin xs ys -> Thin xs (y :: ys)
13 | Keep : Thin xs ys -> Thin (x :: xs) (x :: ys)
16 | none : {xs : List a} -> Thin [] xs
17 | none {xs = []} = Refl
18 | none {xs = _ :: _} = Drop none
23 | keep : Thin xs ys -> Thin (x :: xs) (x :: ys)
28 | keeps : (args : List a) -> Thin xs ys -> Thin (args ++ xs) (args ++ ys)
30 | keeps (x :: xs) th = Keep (keeps xs th)
33 | fromNatSet : NatSet -> (xs : List a) -> (
xs' ** Thin xs' xs)
35 | if isEmpty ns then (
_ ** Refl)
else go 0 xs
37 | go : Nat -> (xs : List a) -> (
xs' ** Thin xs' xs)
38 | go i [] = (
_ ** Refl)
40 | = let (
xs' ** th)
= go (S i) xs in
42 | then (
xs' ** Drop th)
43 | else (
x :: xs' ** Keep th)