MonadFailAny
default implementations
This commit is contained in:
parent
9a8472e8fd
commit
979d1a587a
20
src/func.rs
20
src/func.rs
@ -287,21 +287,35 @@ pub trait MonadFailAny {
|
||||
f: impl 'a + FnOnce(E0) -> E1,
|
||||
) -> <Self::W<E1> as WeakFunctor>::F<'a, A>
|
||||
where
|
||||
Self: 'a;
|
||||
Self: 'a,
|
||||
{
|
||||
Self::bind_err(wa, |e0| Self::fail(f(e0)))
|
||||
}
|
||||
|
||||
fn bind_err<'a, A: 'a, E0: 'a, E1: 'a>(
|
||||
wa: <Self::W<E0> as WeakFunctor>::F<'a, A>,
|
||||
f: impl 'a + FnOnce(E0) -> <Self::W<E1> as WeakFunctor>::F<'a, A>,
|
||||
) -> <Self::W<E1> as WeakFunctor>::F<'a, A>
|
||||
where
|
||||
Self: 'a;
|
||||
Self: 'a,
|
||||
{
|
||||
Self::bind(wa, |result| match result {
|
||||
Ok(a) => Self::pure(a),
|
||||
Err(e0) => f(e0),
|
||||
})
|
||||
}
|
||||
|
||||
fn bind<'a, A: 'a, B: 'a, E0: 'a, E1: 'a>(
|
||||
wa: <Self::W<E0> as WeakFunctor>::F<'a, A>,
|
||||
f: impl 'a + FnOnce(Result<A, E0>) -> <Self::W<E1> as WeakFunctor>::F<'a, B>,
|
||||
) -> <Self::W<E1> as WeakFunctor>::F<'a, B>
|
||||
where
|
||||
Self: 'a;
|
||||
Self: 'a,
|
||||
{
|
||||
Self::stuff(<Self::T as Monad>::bind(Self::unstuff(wa), |result| {
|
||||
Self::unstuff(f(result))
|
||||
}))
|
||||
}
|
||||
|
||||
fn rotate_out<'a, A: 'a, E0: 'a, E1: 'a>(
|
||||
wa: <Self::W<E0> as WeakFunctor>::F<'a, Result<A, E1>>,
|
||||
|
Loading…
Reference in New Issue
Block a user