Skip to main content

Profunctor

Trait Profunctor 

Source
pub trait Profunctor: HKT2 {
    // Required method
    fn dimap<A, B, C, D>(
        f: impl Fn(C) -> A + 'static,
        g: impl Fn(B) -> D + 'static,
        pab: Self::P<A, B>,
    ) -> Self::P<C, D>
       where A: 'static,
             B: 'static;

    // Provided methods
    fn lmap<A, B, C>(
        f: impl Fn(C) -> A + 'static,
        pab: Self::P<A, B>,
    ) -> Self::P<C, B>
       where A: 'static,
             B: 'static { ... }
    fn rmap<A, B, D>(
        g: impl Fn(B) -> D + 'static,
        pab: Self::P<A, B>,
    ) -> Self::P<A, D>
       where A: 'static,
             B: 'static { ... }
}
Expand description

A profunctor is contravariant in its first argument and covariant in its second.

Laws:

  • Identity: dimap(id, id, p) == p
  • Composition: dimap(f . g, h . i, p) == dimap(g, h, dimap(f, i, p))

Required Methods§

Source

fn dimap<A, B, C, D>( f: impl Fn(C) -> A + 'static, g: impl Fn(B) -> D + 'static, pab: Self::P<A, B>, ) -> Self::P<C, D>
where A: 'static, B: 'static,

Provided Methods§

Source

fn lmap<A, B, C>( f: impl Fn(C) -> A + 'static, pab: Self::P<A, B>, ) -> Self::P<C, B>
where A: 'static, B: 'static,

Source

fn rmap<A, B, D>( g: impl Fn(B) -> D + 'static, pab: Self::P<A, B>, ) -> Self::P<A, D>
where A: 'static, B: 'static,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Profunctor for FnP

Source§

impl Profunctor for TaggedF

Source§

impl<R> Profunctor for ForgetF<R>
where R: 'static,