pub trait FunctorSurrogate<F, A>where
    F: HKT1,
    Self: Equiv<To = F::T<A>>,{
    type Output<AB, B>;

    // Required method
    fn map_<AB, B>(self, f: AB) -> Self::Output<AB, B>
       where AB: F1<A, Ret = B>,
             Self::Output<AB, B>: Equiv<To = F::T<B>>;
}
Expand description

Functor but with looser type constraints, allowing for blanket Functor implementations on types Equivalent to F<A>

Required Associated Types§

source

type Output<AB, B>

Type yielded by fmap that is akin to F::T<B>.

The output type may use both type parameters, or only one.

The reason we allow the output to be parameterized by AB (the function from A -> B) is so that the returning type can store the function and defer transformation.

This allows implementing lazy functors with no heap dependency (ex. IO)

Required Methods§

source

fn map_<AB, B>(self, f: AB) -> Self::Output<AB, B>where AB: F1<A, Ret = B>, Self::Output<AB, B>: Equiv<To = F::T<B>>,

Use a function from A -> B to transform something akin to F<A> to something akin to F<B>.

Implementors§

source§

impl<I, A> FunctorSurrogate<IO, A> for Iwhere I: Equiv<To = IO<A>> + IOLike<A>,

§

type Output<AB, B> = Map<AB, A, B, I>