pub trait Bifunctor<'a, A, B> {
type Target<T, U>;
fn bimap<C, D, L, R>(self, left: L, right: R) -> Self::Target<C, D>
where
L: Fn(A) -> C + 'a,
R: Fn(B) -> D + 'a;
fn lmap<C, L>(self, left: L) -> Self::Target<C, B>
where
Self: Sized,
B: 'a,
L: Fn(A) -> C + 'a,
{ ... }
fn rmap<D, R>(self, right: R) -> Self::Target<A, D>
where
Self: Sized,
A: 'a,
R: Fn(B) -> D + 'a,
{ ... }
}
Expand description
A Bifunctor
lets you change the types of a generic type with two type
parameters.
A Bifunctor
works just like a Functor
, but for types
with two type parameters. It will convert a F<_, _>: Bifunctor
from F<A, B>
to F<C, D>
using two functions, one Fn(A) -> C
and the other Fn(B) -> D
.