Tealeaves.Classes.Categorical.TraversableFunctor2
From Tealeaves Require Export
Functors.Compose
Classes.Functor2
Classes.Categorical.Applicative
Classes.Categorical.TraversableFunctor.
Import Functor2.Notations.
#[local] Generalizable Variable T G ϕ A B.
#[local] Arguments map F%function_scope {Map} {A B}%type_scope f%function_scope _.
Functors.Compose
Classes.Functor2
Classes.Categorical.Applicative
Classes.Categorical.TraversableFunctor.
Import Functor2.Notations.
#[local] Generalizable Variable T G ϕ A B.
#[local] Arguments map F%function_scope {Map} {A B}%type_scope f%function_scope _.
Class ApplicativeDist2 (T: Type → Type → Type) :=
dist2: ∀ (G: Type → Type)
`{Map_G: Map G} `{Pure_G: Pure G} `{Mult_G: Mult G},
T ○21 G ⇒2 G ○12 T.
#[global] Arguments dist2 {T}%function_scope {ApplicativeDist2}
{G}%function_scope {Map_G Pure_G Mult_G} {B A}%type_scope.
#[local] Arguments dist2 T%function_scope {ApplicativeDist2}
G%function_scope {Map_G Pure_G Mult_G} {B A}%type_scope.
dist2: ∀ (G: Type → Type)
`{Map_G: Map G} `{Pure_G: Pure G} `{Mult_G: Mult G},
T ○21 G ⇒2 G ○12 T.
#[global] Arguments dist2 {T}%function_scope {ApplicativeDist2}
{G}%function_scope {Map_G Pure_G Mult_G} {B A}%type_scope.
#[local] Arguments dist2 T%function_scope {ApplicativeDist2}
G%function_scope {Map_G Pure_G Mult_G} {B A}%type_scope.
Class TraversableFunctor2
(T: Type → Type → Type)
`{Map2_F: Map2 T}
`{dist2_F: ApplicativeDist2 T} :=
{ trav2_functor :> Functor2 T;
dist2_natural :> ∀ `{Applicative G},
@Natural2 (T ○21 G) _ (G ○12 T) _ (@dist2 T dist2_F G _ _ _);
dist2_morph: ∀ `{ApplicativeMorphism G1 G2 ϕ},
`(dist2 T G2 ∘ map2 (ϕ B) (ϕ A) = ϕ (T B A) ∘ dist2 T G1);
dist2_unit:
`(dist2 T (fun A ⇒ A) = id (A := T B A));
dist2_linear: ∀ `{Applicative G1} `{Applicative G2},
`(dist2 T (G1 ∘ G2) = map G1 (dist2 T G2) ∘
dist2 T G1 (B := G2 B) (A := G2 A));
}.
(T: Type → Type → Type)
`{Map2_F: Map2 T}
`{dist2_F: ApplicativeDist2 T} :=
{ trav2_functor :> Functor2 T;
dist2_natural :> ∀ `{Applicative G},
@Natural2 (T ○21 G) _ (G ○12 T) _ (@dist2 T dist2_F G _ _ _);
dist2_morph: ∀ `{ApplicativeMorphism G1 G2 ϕ},
`(dist2 T G2 ∘ map2 (ϕ B) (ϕ A) = ϕ (T B A) ∘ dist2 T G1);
dist2_unit:
`(dist2 T (fun A ⇒ A) = id (A := T B A));
dist2_linear: ∀ `{Applicative G1} `{Applicative G2},
`(dist2 T (G1 ∘ G2) = map G1 (dist2 T G2) ∘
dist2 T G1 (B := G2 B) (A := G2 A));
}.
Section purity_law.
Context
`{TraversableFunctor2 T}.
(*
Corollary map_purity_1: forall `{Applicative G},
`(dist2 T G ∘ map2 T ((pure G) = pure G (A := T A)).
Proof.
intros. rewrite (dist_morph (ϕ := @pure G _)).
now rewrite (dist_unit).
Qed.
Corollary map_purity_2:
forall `{Applicative G1} `{Applicative G2} `(f: A -> G1 B),
dist T (G2 ∘ G1) ∘ map T (pure G2 ∘ f) = pure G2 ∘ dist T G1 ∘ map T f.
Proof.
intros. rewrite <- (fun_map_map).
reassociate <-. rewrite dist_linear.
reassociate -> near (map T (pure G2)).
rewrite map_purity_1.
fequal. ext t. unfold compose.
now rewrite app_pure_natural.
Qed.
*)
End purity_law.
Context
`{TraversableFunctor2 T}.
(*
Corollary map_purity_1: forall `{Applicative G},
`(dist2 T G ∘ map2 T ((pure G) = pure G (A := T A)).
Proof.
intros. rewrite (dist_morph (ϕ := @pure G _)).
now rewrite (dist_unit).
Qed.
Corollary map_purity_2:
forall `{Applicative G1} `{Applicative G2} `(f: A -> G1 B),
dist T (G2 ∘ G1) ∘ map T (pure G2 ∘ f) = pure G2 ∘ dist T G1 ∘ map T f.
Proof.
intros. rewrite <- (fun_map_map).
reassociate <-. rewrite dist_linear.
reassociate -> near (map T (pure G2)).
rewrite map_purity_1.
fequal. ext t. unfold compose.
now rewrite app_pure_natural.
Qed.
*)
End purity_law.