pub struct ComonadCtx<E, A> { /* private fields */ }Expand description
A comonad-style context: wraps a focused value with an environment.
Models (env, focus) pairs where focus is the current value and
env captures additional context (e.g., for zipper traversal).
Implementations§
Source§impl<E: Clone, A: Clone> ComonadCtx<E, A>
impl<E: Clone, A: Clone> ComonadCtx<E, A>
Sourcepub fn duplicate(&self) -> ComonadCtx<E, ComonadCtx<E, A>>
pub fn duplicate(&self) -> ComonadCtx<E, ComonadCtx<E, A>>
Duplicate: produce a context focused on itself.
Sourcepub fn extend<B, F: Fn(&ComonadCtx<E, A>) -> B>(&self, f: F) -> ComonadCtx<E, B>
pub fn extend<B, F: Fn(&ComonadCtx<E, A>) -> B>(&self, f: F) -> ComonadCtx<E, B>
Extend: apply a function to the whole context, producing a new context.
Sourcepub fn map<B, F: FnOnce(A) -> B>(self, f: F) -> ComonadCtx<E, B>
pub fn map<B, F: FnOnce(A) -> B>(self, f: F) -> ComonadCtx<E, B>
Map over the focused value.
Trait Implementations§
Auto Trait Implementations§
impl<E, A> Freeze for ComonadCtx<E, A>
impl<E, A> RefUnwindSafe for ComonadCtx<E, A>where
E: RefUnwindSafe,
A: RefUnwindSafe,
impl<E, A> Send for ComonadCtx<E, A>
impl<E, A> Sync for ComonadCtx<E, A>
impl<E, A> Unpin for ComonadCtx<E, A>
impl<E, A> UnsafeUnpin for ComonadCtx<E, A>where
E: UnsafeUnpin,
A: UnsafeUnpin,
impl<E, A> UnwindSafe for ComonadCtx<E, A>where
E: UnwindSafe,
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more