pub struct BoxWitness;Expand description
BoxWitness is a zero-sized type that acts as a Higher-Kinded Type (HKT) witness
for the Box<T> type constructor. It allows Box to be used with generic
functional programming traits like Functor, Applicative, Foldable, and Monad.
By implementing HKT for BoxWitness, we can write generic functions that operate
on any type that has the “shape” of Box, without knowing the inner type T.
Trait Implementations§
Source§impl Applicative<BoxWitness> for BoxWitness
impl Applicative<BoxWitness> for BoxWitness
Source§fn apply<A, B, Func>(
f_ab: <BoxWitness as HKT>::Type<Func>,
f_a: <BoxWitness as HKT>::Type<A>,
) -> <BoxWitness as HKT>::Type<B>
fn apply<A, B, Func>( f_ab: <BoxWitness as HKT>::Type<Func>, f_a: <BoxWitness as HKT>::Type<A>, ) -> <BoxWitness as HKT>::Type<B>
Source§impl CoMonad<BoxWitness> for BoxWitness
impl CoMonad<BoxWitness> for BoxWitness
Source§impl Foldable<BoxWitness> for BoxWitness
impl Foldable<BoxWitness> for BoxWitness
Source§impl Functor<BoxWitness> for BoxWitness
impl Functor<BoxWitness> for BoxWitness
Source§fn fmap<A, B, Func>(
m_a: <BoxWitness as HKT>::Type<A>,
f: Func,
) -> <BoxWitness as HKT>::Type<B>where
Func: FnOnce(A) -> B,
fn fmap<A, B, Func>(
m_a: <BoxWitness as HKT>::Type<A>,
f: Func,
) -> <BoxWitness as HKT>::Type<B>where
Func: FnOnce(A) -> B,
Source§impl HKT for BoxWitness
impl HKT for BoxWitness
Source§impl Monad<BoxWitness> for BoxWitness
impl Monad<BoxWitness> for BoxWitness
Source§fn bind<A, B, Func>(
m_a: <BoxWitness as HKT>::Type<A>,
f: Func,
) -> <BoxWitness as HKT>::Type<B>
fn bind<A, B, Func>( m_a: <BoxWitness as HKT>::Type<A>, f: Func, ) -> <BoxWitness as HKT>::Type<B>
Auto Trait Implementations§
impl Freeze for BoxWitness
impl RefUnwindSafe for BoxWitness
impl Send for BoxWitness
impl Sync for BoxWitness
impl Unpin for BoxWitness
impl UnwindSafe for BoxWitness
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