0 | module Data.Filterable.Indexed
2 | import public Data.Filterable
3 | import public Data.Functor.Indexed
9 | interface (Filterable t,
IndFunctor i t) => IndFilterable i t | t where
10 | imapMaybe : (i -> a -> Maybe b) -> t a -> t b
13 | IndFilterable () Maybe where
14 | imapMaybe f = mapMaybe (f ())
20 | enumFilter : (Nat -> a -> Maybe b) -> List a -> List b
21 | enumFilter f = inner 0 where
22 | inner : Nat -> List a -> List b
24 | inner n (x::xs) = case f n x of
25 | Just y => y::inner (n+1) xs
26 | Nothing => inner (n+1) xs