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.

Required Associated Types§

Required Methods§

Map a Bifunctor<A, B> to a Bifunctor<C, D> using a function from A to C and a function from B to D.

Provided Methods§

Map only the left hand side of the bifunctor from A to C.

Map only the right hand side of the bifunctor from B to D.

Implementations on Foreign Types§

Implementors§