Trait naan::monad::MonadSurrogate
source · 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
Required Associated Types§
sourcetype BindOutput<B, AMB>
type BindOutput<B, AMB>
Type yielded by bind_
that isn’t exactly M::T<B>
, but
is conceptually Equiv
alent.
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§
sourcefn 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>>,
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>
.