pub trait MonadSurrogate<M, A>where
    Self: Equiv<To = M::T<A>> + ApplicativeSurrogate<M, A>,
    M: HKT1,{
    type BindOutput<B, AMB>;

    // Required method
    fn bind_<B, AMB>(self, f: AMB) -> Self::BindOutput<B, AMB>
       where AMB: F1<A, Ret = M::T<B>>,
             Self::BindOutput<B, AMB>: Equiv<To = M::T<B>>;
}
Expand description

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

Required Associated Types§

source

type BindOutput<B, AMB>

Type yielded by bind_ that isn’t exactly M::T<B>, but is conceptually Equivalent.

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

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

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

Required Methods§

source

fn bind_<B, AMB>(self, f: AMB) -> Self::BindOutput<B, AMB>where AMB: F1<A, Ret = M::T<B>>, Self::BindOutput<B, AMB>: Equiv<To = M::T<B>>,

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

Implementors§

source§

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

§

type BindOutput<B, AMB> = Bind<AMB, A, B, I>