diff --git a/src/rcore/resolver_origin.rs b/src/rcore/resolver_origin.rs index 2ab3aeb..6690d3f 100644 --- a/src/rcore/resolver_origin.rs +++ b/src/rcore/resolver_origin.rs @@ -28,7 +28,7 @@ fn _resolve_origin<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>>( origin: Rc>, ) -> Resolution<'a, Ctx, A> { let resolution = origin.r_resolver.clone().resolve(origin.r_address); - Ctx::T::fmap(resolution, move |resolved| { + Ctx::fmap(resolution, move |resolved| { let (src, resolver) = resolved.map_err(ResolutionError::Lookup)?; let mentionable = origin .r_factory diff --git a/src/rstd/cast.rs b/src/rstd/cast.rs index c40fcac..5281d9c 100644 --- a/src/rstd/cast.rs +++ b/src/rstd/cast.rs @@ -5,6 +5,7 @@ use std::convert::identity; +use crate::func::context::*; use crate::rcore::*; use super::{typeless::*, wrapped_origin::*, *}; @@ -65,7 +66,7 @@ impl<'a> CastError<'a> { where Ctx::LookupError: From>, { - Ctx::T::pure(Err(self.into())) + Ctx::pure(Err(self.into())) } } @@ -143,7 +144,7 @@ where Ok(point) => point, Err(cast_error) => return cast_error.pure::(), }; - Ctx::T::fmap(point.resolve(), cast_resolved) + Ctx::fmap(point.resolve(), cast_resolved) } } @@ -178,7 +179,7 @@ fn cast_resolve<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>>( where Ctx::LookupError: From>, { - Ctx::T::fmap( + Ctx::fmap( typeless_origin.clone().resolve(), move |resolved| match resolved { Ok(typeless_mentionable) => match typeless_mentionable.cast(factory) { diff --git a/src/rstd/collections/avl/binary.rs b/src/rstd/collections/avl/binary.rs index 0bab368..fdd1007 100644 --- a/src/rstd/collections/avl/binary.rs +++ b/src/rstd/collections/avl/binary.rs @@ -1,4 +1,4 @@ -use crate::func::*; +use crate::func::context::*; use super::*; @@ -76,7 +76,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> AvlTree<'a, Ctx, A> { impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> AvlReference<'a, Ctx, A> { pub fn resolve(&self) -> Resolution<'a, Ctx, AvlNode<'a, Ctx, A>> { let parent_height = self.parent_height; - ::fmap(self.node.resolve(), move |resolved| { + Ctx::fmap(self.node.resolve(), move |resolved| { let node = resolved?; node.matches_height(parent_height) .map_err(ResolutionError::Parse)?; diff --git a/src/rstd/collections/avl/bounds.rs b/src/rstd/collections/avl/bounds.rs index 819e833..fefa3f6 100644 --- a/src/rstd/collections/avl/bounds.rs +++ b/src/rstd/collections/avl/bounds.rs @@ -1,5 +1,5 @@ use crate::flow::comparator::*; -use crate::func::*; +use crate::func::context::*; use super::{binary::*, *}; @@ -152,8 +152,8 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> BoundNode<'a, Ctx, A> { pub fn into_tree_resolution(self) -> BrTree<'a, Ctx, A> { match self.into_tree() { - Ok(tree) => ::pure(Ok(tree)), - Err(e) => ::pure(Err(ResolutionError::Parse(e))), + Ok(tree) => Ctx::pure(Ok(tree)), + Err(e) => Ctx::pure(Err(ResolutionError::Parse(e))), } } @@ -218,7 +218,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> BoundTree<'a, Ctx, A> { factory: Fctr<'a, Ctx, A>, comparator: Rc>, ) -> BrKeySplit<'a, Ctx, A> { - ::pure( + Ctx::pure( Self::split_empty(self.bounds, &key, &factory, comparator.as_ref()) .map_err(BoundError::Bounds) .map_err(ResolutionError::Parse), @@ -251,7 +251,7 @@ pub type BrKeySplit<'a, Ctx, A> = BoundResolution<'a, Ctx, A, BoundKeySplit<'a, impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> BoundReference<'a, Ctx, A> { pub fn resolve(&self, comparator: Rc>) -> BrNode<'a, Ctx, A> { let bounds = self.bounds.clone(); - ::fmap(self.reference.resolve(), move |resolved| { + Ctx::fmap(self.reference.resolve(), move |resolved| { let node = resolved .map_err(|e| e.map_parse(BoundError::Avl))? .as_ref() diff --git a/src/rstd/collections/stack.rs b/src/rstd/collections/stack.rs index 129ee98..1243168 100644 --- a/src/rstd/collections/stack.rs +++ b/src/rstd/collections/stack.rs @@ -1,5 +1,6 @@ //! Basic implementation of a stack/linked list. +use crate::func::context::*; use crate::rcore::*; use crate::rstd::{inlining::*, nullable::*, point::*, *}; @@ -156,8 +157,8 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> ExtStack<'a, Ctx, A> for Sta } fn vec(self) -> StackVecWrapped<'a, Ctx, A> { Ctx::T::iterate_mut((vec![], self), |(mut vec, stack)| match stack { - Nullable::Null(_) => Ctx::T::pure(ControlFlow::Break(Ok(vec))), - Nullable::NotNull(point) => Ctx::T::fmap(point.resolve(), |resolved| { + Nullable::Null(_) => Ctx::pure(ControlFlow::Break(Ok(vec))), + Nullable::NotNull(point) => Ctx::fmap(point.resolve(), |resolved| { let node = match resolved { Ok(node) => node, Err(error) => { diff --git a/src/rstd/fallible.rs b/src/rstd/fallible.rs index 57c97df..7a0868b 100644 --- a/src/rstd/fallible.rs +++ b/src/rstd/fallible.rs @@ -1,7 +1,6 @@ //! Shorthands for using [`Context::Fallible`]. -#[cfg(doc)] -use crate::func::context::FunctorContext; +use crate::func::context::*; use super::*; @@ -17,14 +16,12 @@ pub type FallibleWrapped<'a, Ctx, A, E> = Wrap<'a, A, FallibleMonad<'a, Ctx, E>> /// this is the preferred way to switch between [Wrapped] and [fallible]. pub trait FallibleContext<'a>: Context<'a> { /// Convert a fallible wrapped into a wrapped result. - fn unstuff( - wa: WrapE<'a, A, E, Self::Fallible>, - ) -> Wrap<'a, Result, Self::T> { + fn unstuff(wa: WrapE<'a, A, E, Self::Fallible>) -> WrapC<'a, Result, Self> { Self::Fallible::unstuff(wa) } /// Convert a wrapped result into a fallible wrapped. - fn stuff(fa: Wrap<'a, Result, Self::T>) -> WrapE<'a, A, E, Self::Fallible> { + fn stuff(fa: WrapC<'a, Result, Self>) -> WrapE<'a, A, E, Self::Fallible> { Self::Fallible::stuff(fa) } } diff --git a/src/rstd/local_origin.rs b/src/rstd/local_origin.rs index c1170d3..926c79f 100644 --- a/src/rstd/local_origin.rs +++ b/src/rstd/local_origin.rs @@ -1,9 +1,8 @@ use std::rc::Rc; +use crate::func::context::*; use crate::rcore::*; -use super::*; - impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Point<'a, Ctx, A> { fn prepare_bytes_for_hashing(mentioned: &A) -> Vec { let mut vec = mentioned.topology().to_vec(); @@ -37,7 +36,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Origin<'a, Ctx> for LocalOri } fn resolve(self: Rc) -> Resolution<'a, Ctx, Self::Mtbl> { - Ctx::T::pure(Ok(self.0.clone())) + Ctx::pure(Ok(self.0.clone())) } } diff --git a/src/rstd/nullable.rs b/src/rstd/nullable.rs index 75b670e..86cee50 100644 --- a/src/rstd/nullable.rs +++ b/src/rstd/nullable.rs @@ -1,5 +1,6 @@ //! This module introduces [`Option`]-like concepts into RADN typesystem using [`Nullable`]. +use crate::func::context::*; use crate::rcore::*; use super::{inlining::*, point::*, *}; @@ -80,7 +81,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> Nullable<'a, Ctx, Nullable<' match self { Self::Null(nullable_factory) => { let NullableFactory { factory } = nullable_factory; - Ctx::T::pure(Ok(Rc::new(Nullable::Null(factory.clone())))) + Ctx::pure(Ok(Rc::new(Nullable::Null(factory.clone())))) } Self::NotNull(point) => point.resolve(), } diff --git a/src/rstd/wrapped_origin.rs b/src/rstd/wrapped_origin.rs index 48b53cf..8a46115 100644 --- a/src/rstd/wrapped_origin.rs +++ b/src/rstd/wrapped_origin.rs @@ -1,3 +1,5 @@ +use crate::func::context::*; + use super::*; pub fn wrapped_origin<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>>( @@ -42,7 +44,7 @@ fn map_resolve<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>, B: Mentionable<'a, map_ok: impl 'a + Fn(Rc) -> B, map_err: impl 'a + Fn(ParseError<'a, Ctx, A::Fctr>) -> ParseError<'a, Ctx, B::Fctr>, ) -> Resolution<'a, Ctx, B> { - Ctx::T::fmap(resolve(), move |resolved| match resolved { + Ctx::fmap(resolve(), move |resolved| match resolved { Ok(mentionable) => Ok(Rc::new(map_ok(mentionable))), Err(e) => Err(e.map_parse(map_err)), }) diff --git a/src/testing/inject.rs b/src/testing/inject.rs index 1cdbcee..4ba9a88 100644 --- a/src/testing/inject.rs +++ b/src/testing/inject.rs @@ -1,6 +1,6 @@ use std::rc::Rc; -use crate::func::*; +use crate::func::context::*; use crate::rcore::*; trait Inject<'a, Ctx: Context<'a>>: 'a { @@ -15,7 +15,7 @@ struct InjectedResolver<'a, Ctx: Context<'a>, F: Inject<'a, Ctx>> { impl<'a, Ctx: Context<'a>, F: Inject<'a, Ctx>> Resolver<'a, Ctx> for InjectedResolver<'a, Ctx, F> { fn resolve(self: Rc, address: crate::rcore::Address) -> HashResolution<'a, Ctx> { let inject = self.inject.clone(); - ::fmap( + Ctx::fmap( self.resolver.clone().resolve(address), |resolved| match resolved { Ok((source, resolver)) => Ok((