ExtContext
This commit is contained in:
parent
6a19cdaf81
commit
8314dfa320
34
src/std.rs
34
src/std.rs
@ -35,3 +35,37 @@ impl<S: Serializable> ExtSerializable for S {
|
||||
vec
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ExtContext: Context {
|
||||
fn unstuff<'a, A: 'a, E: 'a>(
|
||||
wa: <<Self::Fallible as MonadFailAny>::W<E> as WeakFunctor>::F<'a, A>,
|
||||
) -> <Self::T as WeakFunctor>::F<'a, Result<A, E>>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
fn stuff<'a, A: 'a, E: 'a>(
|
||||
fa: <Self::T as WeakFunctor>::F<'a, Result<A, E>>,
|
||||
) -> <<Self::Fallible as MonadFailAny>::W<E> as WeakFunctor>::F<'a, A>
|
||||
where
|
||||
Self: 'a;
|
||||
}
|
||||
|
||||
impl<Ctx: Context> ExtContext for Ctx {
|
||||
fn unstuff<'a, A: 'a, E: 'a>(
|
||||
wa: <<Self::Fallible as MonadFailAny>::W<E> as WeakFunctor>::F<'a, A>,
|
||||
) -> <Self::T as WeakFunctor>::F<'a, Result<A, E>>
|
||||
where
|
||||
Self: 'a,
|
||||
{
|
||||
Self::Fallible::unstuff(wa)
|
||||
}
|
||||
|
||||
fn stuff<'a, A: 'a, E: 'a>(
|
||||
fa: <Self::T as WeakFunctor>::F<'a, Result<A, E>>,
|
||||
) -> <<Self::Fallible as MonadFailAny>::W<E> as WeakFunctor>::F<'a, A>
|
||||
where
|
||||
Self: 'a,
|
||||
{
|
||||
Self::Fallible::stuff(fa)
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ use std::rc::Rc;
|
||||
|
||||
use crate::flow::traversible::*;
|
||||
use crate::func::*;
|
||||
use crate::std::fallible::*;
|
||||
use crate::std::{fallible::*, *};
|
||||
|
||||
use super::*;
|
||||
|
||||
@ -96,7 +96,7 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>>
|
||||
> {
|
||||
<SubsetMonad<'a, Ctx, A> as Functor>::fmap(
|
||||
|resolved| resolved as Rc<dyn TraversibleBinaryNode<'a, _, _, _>>,
|
||||
self.resolve(),
|
||||
Ctx::stuff(self.resolve()),
|
||||
)
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>>
|
||||
> {
|
||||
<SubsetMonad<'a, Ctx, A> as Functor>::fmap(
|
||||
|resolved| resolved as Rc<dyn TraversibleBinaryNode<'a, _, _, _>>,
|
||||
self.resolve(),
|
||||
Ctx::stuff(self.resolve()),
|
||||
)
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>>
|
||||
> {
|
||||
<SubsetMonad<'a, Ctx, A> as Functor>::fmap(
|
||||
|resolved| resolved as Rc<dyn TraversibleBinaryNode<'a, _, _, _>>,
|
||||
self.resolve(),
|
||||
Ctx::stuff(self.resolve()),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
use crate::func::classes::{composition::*, result::*};
|
||||
|
||||
use super::*;
|
||||
|
||||
pub type FallibleMonad<Ctx, E> = CompositionClass<<Ctx as Context>::T, ResultClass<E>>;
|
||||
pub type FallibleMonad<Ctx, E> = <<Ctx as Context>::Fallible as MonadFailAny>::W<E>;
|
||||
|
||||
pub type FallibleWrapped<'a, Ctx, A, E> = <FallibleMonad<Ctx, E> as WeakFunctor>::F<'a, A>;
|
||||
|
Loading…
Reference in New Issue
Block a user