Compare commits

..

No commits in common. "bd361833b557d951d0683e5dd99242c75976eb01" and "0abdfe9751d3759ff54925fdd0b63a0612f8bb1a" have entirely different histories.

3 changed files with 1 additions and 78 deletions

View File

@ -15,7 +15,7 @@ pub enum Comparison {
R,
}
fn and(_l: (), _r: ()) {}
fn and(_l: (), _r: ()) -> () {}
/// Returns [`Comparison`] saying which value is smaller.
///

View File

@ -247,25 +247,6 @@ pub trait MonadFailAny {
) -> <Self::W<E1> as WeakFunctor>::F<'a, A>
where
Self: 'a;
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;
fn rotate_out<'a, A: 'a, E0: 'a, E1: 'a>(
wa: <Self::W<E0> as WeakFunctor>::F<'a, Result<A, E1>>,
) -> <Self::W<Result<E1, E0>> as WeakFunctor>::F<'a, A>
where
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 MonadFail<Result<E1, E0>>>::fail(Ok(e)),
})
}
}
/// Represents a (collection of) [Monad]\(s),

View File

@ -161,19 +161,6 @@ impl<E> MonadFail<E> for ResultClass<E> {
pub struct ResultFailAny;
trait ResultExt<'a, A: 'a, E0: 'a>: 'a {
fn bind_err<E1: 'a>(self, f: impl 'a + FnOnce(E0) -> Result<A, E1>) -> Result<A, E1>;
}
impl<'a, A: 'a, E0: 'a> ResultExt<'a, A, E0> for Result<A, E0> {
fn bind_err<E1: 'a>(self, f: impl 'a + FnOnce(E0) -> Result<A, E1>) -> Result<A, E1> {
match self {
Ok(a) => Ok(a),
Err(e) => f(e),
}
}
}
impl MonadFailAny for ResultFailAny {
type W<E> = ResultClass<E>;
@ -186,29 +173,6 @@ impl MonadFailAny for ResultFailAny {
{
wa.map_err(f)
}
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,
{
wa.bind_err(f)
}
fn rotate_out<'a, A: 'a, E0: 'a, E1: 'a>(
wa: <Self::W<E0> as WeakFunctor>::F<'a, Result<A, E1>>,
) -> <Self::W<Result<E1, E0>> as WeakFunctor>::F<'a, A>
where
Self: 'a,
{
match wa {
Ok(Ok(a)) => Ok(a),
Ok(Err(e)) => Err(Ok(e)),
Err(e) => Err(Err(e)),
}
}
}
impl MonadFailOver<classes::solo::SoloClass> for ResultFailAny {
@ -247,28 +211,6 @@ impl<T: Monad> MonadFailAny for ResultFailOver<T> {
{
T::fmap(|a| a.map_err(f), wa)
}
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,
{
T::bind(wa, |a| match a {
Ok(a) => T::pure(Ok(a)),
Err(e) => f(e),
})
}
fn rotate_out<'a, A: 'a, E0: 'a, E1: 'a>(
wa: <Self::W<E0> as WeakFunctor>::F<'a, Result<A, E1>>,
) -> <Self::W<Result<E1, E0>> as WeakFunctor>::F<'a, A>
where
Self: 'a,
{
T::fmap(<ResultFailAny as MonadFailAny>::rotate_out, wa)
}
}
impl<T: Monad> MonadFailOver<T> for ResultFailOver<T> {