Skip to main content

ContF

Struct ContF 

Source
pub struct ContF<R>(/* private fields */);
Expand description

A contravariant functor type constructor: Of<A> = Box<dyn Fn(A) -> R>.

This is the “Op” or “Cont” functor, generalizing PredicateF (which is ContF<bool>). It is contravariant: given f: B -> A, we get ContF<R>::Of<A> -> ContF<R>::Of<B> by pre-composing with f.

ContF<R> is self-adjoint as a contravariant functor, giving rise to the continuation monad (A -> R) -> R via ContF<R> . ContF<R>.

Trait Implementations§

Source§

impl<R> Contravariant for ContF<R>
where R: 'static,

Available on crate features std or alloc only.
Source§

fn contramap<A, B>( fa: <ContF<R> as HKT>::Of<A>, f: impl Fn(B) -> A + 'static, ) -> <ContF<R> as HKT>::Of<B>
where A: 'static,

Source§

impl<R> ContravariantAdjunction<ContF<R>, ContF<R>> for ContAdj<R>
where R: 'static,

Available on crate features std or alloc only.
Source§

fn unit<A>(a: A) -> Box<dyn Fn(Box<dyn Fn(A) -> R>) -> R>
where A: Clone + 'static,

unit: A -> G(F(A)) Read more
Source§

fn counit<B>(b: B) -> Box<dyn Fn(Box<dyn Fn(B) -> R>) -> R>
where B: Clone + 'static,

counit: B -> F(G(B)) Read more
Source§

impl<R> HKT for ContF<R>
where R: 'static,

Available on crate features std or alloc only.
Source§

type Of<T> = Box<dyn Fn(T) -> R>

Auto Trait Implementations§

§

impl<R> Freeze for ContF<R>

§

impl<R> RefUnwindSafe for ContF<R>
where R: RefUnwindSafe,

§

impl<R> Send for ContF<R>
where R: Send,

§

impl<R> Sync for ContF<R>
where R: Sync,

§

impl<R> Unpin for ContF<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for ContF<R>

§

impl<R> UnwindSafe for ContF<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.