Bitraversable type class #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
Type class for traversing bifunctors.
Simple examples of bitraversable
are prod
and sum
. A more elaborate example is
to define an a-list as:
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 thebitraverse
function.is_lawful_bitraversable
: Typeclass for the laws of thebitraverse
function. Similar tois_lawful_traversable
.
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
- to_bifunctor : bifunctor t
- bitraverse : Π {m : Type ? → Type ?} [_inst_1 : applicative m] {α α' β β' : Type ?}, (α → m α') → (β → m β') → t α β → m (t α' β')
Lawless bitraversable bifunctor. This only holds data for the bimap and bitraverse.
Instances of this typeclass
Instances of other typeclasses for bitraversable
- bitraversable.has_sizeof_inst
A bitraversable functor commutes with all applicative functors.
Equations
- to_is_lawful_bifunctor : is_lawful_bifunctor t
- id_bitraverse : ∀ {α β : Type ?} (x : t α β), bitraversable.bitraverse id.mk id.mk x = id.mk x
- comp_bitraverse : ∀ {F G : Type ? → Type ?} [_inst_1_1 : applicative F] [_inst_2 : applicative G] [_inst_3 : is_lawful_applicative F] [_inst_4 : is_lawful_applicative G] {α α' β β' γ γ' : Type ?} (f : β → F γ) (f' : β' → F γ') (g : α → G β) (g' : α' → G β') (x : t α α'), bitraversable.bitraverse (functor.comp.mk ∘ functor.map f ∘ g) (functor.comp.mk ∘ functor.map f' ∘ g') x = functor.comp.mk (bitraversable.bitraverse f f' <$> bitraversable.bitraverse g g' x)
- bitraverse_eq_bimap_id : ∀ {α α' β β' : Type ?} (f : α → β) (f' : α' → β') (x : t α α'), bitraversable.bitraverse (id.mk ∘ f) (id.mk ∘ f') x = id.mk (bifunctor.bimap f f' x)
- binaturality : ∀ {F G : Type ? → Type ?} [_inst_1_1 : applicative F] [_inst_2 : applicative G] [_inst_3 : is_lawful_applicative F] [_inst_4 : is_lawful_applicative G] (η : applicative_transformation F G) {α α' β β' : Type ?} (f : α → F β) (f' : α' → F β') (x : t α α'), ⇑η (bitraversable.bitraverse f f' x) = bitraversable.bitraverse (⇑η ∘ f) (⇑η ∘ f') x
Bifunctor. This typeclass asserts that a lawless bitraversable bifunctor is lawful.
Instances of this typeclass
Instances of other typeclasses for is_lawful_bitraversable
- is_lawful_bitraversable.has_sizeof_inst