Transferring Traversable
instances along isomorphisms #
This file allows to transfer Traversable
instances along isomorphisms.
Main declarations #
Equiv.map
: Turns functorially a functionα → β
into a functiont' α → t' β
using the functort
and the equivalenceΠ α, t α ≃ t' α
.Equiv.functor
:Equiv.map
as a functor.Equiv.traverse
: Turns traversably a functionα → m β
into a functiont' α → m (t' β)
using the traversable functort
and the equivalenceΠ α, t α ≃ t' α
.Equiv.traversable
:Equiv.traverse
as a traversable functor.Equiv.isLawfulTraversable
:Equiv.traverse
as a lawful traversable functor.
Given a functor t
, a function t' : Type u → Type u
, and
equivalences t α ≃ t' α
for all α
, then every function α → β
can
be mapped to a function t' α → t' β
functorially (see
Equiv.functor
).
Instances For
The function Equiv.map
transfers the functoriality of t
to
t'
using the equivalences eqv
.
Equations
- Equiv.functor eqv = { map := fun {α β : Type ?u.34} => Equiv.map eqv, mapConst := fun {α β : Type ?u.34} => Equiv.map eqv ∘ Function.const β }
Instances For
Like Equiv.map
, a function t' : Type u → Type u
can be given
the structure of a traversable functor using a traversable functor
t'
and equivalences t α ≃ t' α
for all α. See Equiv.traversable
.
Equations
- Equiv.traverse eqv f x = ⇑(eqv β) <$> traverse f ((eqv α).symm x)
Instances For
The function Equiv.traverse
transfers a traversable functor
instance across the equivalences eqv
.
Equations
- Equiv.traversable eqv = Traversable.mk fun {m : Type ?u.33 → Type ?u.33} [Applicative m] {α β : Type ?u.33} => Equiv.traverse eqv
Instances For
The fact that t
is a lawful traversable functor carries over the
equivalences to t'
, with the traversable functor structure given by
Equiv.traversable
.
If the Traversable t'
instance has the properties that map
,
map_const
, and traverse
are equal to the ones that come from
carrying the traversable functor structure from t
over the
equivalences, then the fact that t
is a lawful traversable functor
carries over as well.