1 | module Data.Withering.Dependent
3 | import Data.Indexed.FixedDep
4 | import Data.Indexed.Independent
5 | import Data.Witherable.Dependent
6 | import Data.Witherable.Indexed
7 | import Data.Withering
11 | data DepWithering : (Type -> Type) -> (i : Type) -> (i -> Type) -> (i -> Type) -> Type where
12 | MkDepWithering : Applicative f
13 | => ({0 t : (i -> Type) -> Type} -> (DepWitherable i t) => t u -> f (t v))
14 | -> DepWithering f i u v
17 | runDepWither : (DepWitherable i t) => DepWithering f i u v -> t u -> f (t v)
18 | runDepWither (MkDepWithering w) m = w m
21 | depWitherOne : DepWithering f i u v -> (x : i) -> u x -> f (Maybe (v x))
22 | depWitherOne (MkDepWithering w) x y = let
23 | z : FixDepIndex x Maybe u
24 | z = WithDepIndex (Just y)
30 | preserving : Applicative f => DepWithering f i u u
31 | preserving = MkDepWithering (pure . id)
34 | flushing : Applicative f => DepWithering f i u v
35 | flushing = MkDepWithering (pure . flush)
38 | mapping : Applicative f => ((x : i) -> u x -> v x) -> DepWithering f i u v
39 | mapping f = MkDepWithering (pure . dmap f)
42 | mapMaybeing : Applicative f => ((x : i) -> u x -> Maybe (v x)) -> DepWithering f i u v
43 | mapMaybeing f = MkDepWithering (pure . dmapMaybe f)
46 | traversing : Applicative f => ((x : i) -> u x -> f (v x)) -> DepWithering f i u v
47 | traversing f = MkDepWithering (dtraverse f)
50 | withering : Applicative f => ((x : i) -> u x -> f (Maybe (v x))) -> DepWithering f i u v
51 | withering f = MkDepWithering (dwither f)
55 | depWithering : Withering f i a b -> DepWithering f i (const a) (const b)
56 | depWithering (MkWithering w) = MkDepWithering (map dep . w @{independentWitherable} . Indep)