MonadFailAnyExt
This commit is contained in:
parent
f1138501ca
commit
324f99362f
21
src/func.rs
21
src/func.rs
@ -300,12 +300,29 @@ pub trait MonadFailAny {
|
||||
Self: 'a,
|
||||
{
|
||||
<Self::W<Result<E1, E0>> as Monad>::bind(Self::map_err(wa, Err), |fa| match fa {
|
||||
Ok(a) => <Self::W<Result<E1, E0>> as Pure>::pure(a),
|
||||
Err(e) => <Self::W<Result<E1, E0>> as Fail<Result<E1, E0>>>::fail(Ok(e)),
|
||||
Ok(a) => Self::pure(a),
|
||||
Err(e) => Self::fail(Ok(e)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub trait MonadFailAnyExt: MonadFailAny {
|
||||
fn pure<'a, E: 'a, A: 'a>(a: A) -> <Self::W<E> as WeakFunctor>::F<'a, A>
|
||||
where
|
||||
Self: 'a,
|
||||
{
|
||||
<Self::W<E> as Pure>::pure(a)
|
||||
}
|
||||
fn fail<'a, E: 'a, A: 'a>(e: E) -> <Self::W<E> as WeakFunctor>::F<'a, A>
|
||||
where
|
||||
Self: 'a,
|
||||
{
|
||||
<Self::W<E> as Fail<E>>::fail(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl<Fallible: ?Sized + MonadFailAny> MonadFailAnyExt for Fallible {}
|
||||
|
||||
/// Represents a (collection of) [Monad]\(s),
|
||||
/// wrapped values of which are interchangeable with another [Monad]'s
|
||||
/// wrapped [Result]s.
|
||||
|
Loading…
Reference in New Issue
Block a user