Bitraversable type class #
Type class for traversing bifunctors.
Simple examples of Bitraversable are Prod and Sum. A more elaborate example is
to define an a-list as:
def AList (key val : Type) := List (key × val)
Then we can use f : key → IO key' and g : val → IO val' to manipulate the AList's key
and value respectively with bitraverse f g : AList key val → IO (AList key' val').
Main definitions #
Bitraversable: Bare typeclass to hold thebitraversefunction.LawfulBitraversable: Typeclass for the laws of thebitraversefunction. Similar toLawfulTraversable.
References #
The concepts and laws are taken from https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Bitraversable.html
Tags #
traversable bitraversable iterator functor bifunctor applicative
Lawless bitraversable bifunctor. This only holds data for the bimap and bitraverse.
- bitraverse {m : Type u → Type u} [Applicative m] {α α' β β' : Type u} : (α → m α') → (β → m β') → t α β → m (t α' β')
Instances
A bitraversable functor commutes with all applicative functors.
Equations
Instances For
Bifunctor. This typeclass asserts that a lawless bitraversable bifunctor is lawful.
- comp_bitraverse {F G : Type u → Type u} [Applicative F] [Applicative G] [LawfulApplicative F] [LawfulApplicative G] {α α' β β' γ γ' : Type u} (f : β → F γ) (f' : β' → F γ') (g : α → G β) (g' : α' → G β') (x : t α α') : bitraverse (Functor.Comp.mk ∘ Functor.map f ∘ g) (Functor.Comp.mk ∘ Functor.map f' ∘ g') x = Functor.Comp.mk (bitraverse f f' <$> bitraverse g g' x)
- binaturality {F G : Type u → Type u} [Applicative F] [Applicative G] [LawfulApplicative F] [LawfulApplicative G] (η : ApplicativeTransformation F G) {α α' β β' : Type u} (f : α → F β) (f' : α' → F β') (x : t α α') : (fun {α : Type u} => η.app α) (bitraverse f f' x) = bitraverse ((fun {α : Type u} => η.app α) ∘ f) ((fun {α : Type u} => η.app α) ∘ f') x