Skip to main content

FnA

Struct FnA 

Source
pub struct FnA;
Expand description

Marker type whose P<A, B> is Box<dyn Fn(A) -> B>.

This is the canonical Arrow instance: the function arrow. Equivalent to FnP in karpal-profunctor but independent (no cross-crate dep).

Trait Implementations§

Source§

impl Arrow for FnA

Source§

fn arr<A, B>(f: impl Fn(A) -> B + 'static) -> Box<dyn Fn(A) -> B>
where A: Clone + 'static, B: Clone + 'static,

Lift a pure function into an arrow.
Source§

fn first<A, B, C>(pab: Box<dyn Fn(A) -> B>) -> Box<dyn Fn((A, C)) -> (B, C)>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

Apply an arrow to the first component of a pair, passing the second through.
Source§

fn second<A, B, C>(pab: Box<dyn Fn(A) -> B>) -> Box<dyn Fn((C, A)) -> (C, B)>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

Apply an arrow to the second component of a pair.
Source§

fn split<A, B, C, D>( f: Self::P<A, B>, g: Self::P<C, D>, ) -> Self::P<(A, C), (B, D)>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static, D: Clone + 'static,

***: apply two arrows in parallel on a product.
Source§

fn fanout<A, B, C>(f: Self::P<A, B>, g: Self::P<A, C>) -> Self::P<A, (B, C)>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

&&&: feed input to two arrows and collect results as a pair.
Source§

impl ArrowApply for FnA

Source§

fn app<A, B>() -> Box<dyn Fn((Box<dyn Fn(A) -> B>, A)) -> B>
where A: Clone + 'static, B: Clone + 'static,

Source§

impl ArrowChoice for FnA

Source§

fn left<A, B, C>( pab: Box<dyn Fn(A) -> B>, ) -> Box<dyn Fn(Result<A, C>) -> Result<B, C>>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

Route the Ok branch through the arrow, passing Err through.
Source§

fn right<A, B, C>( pab: Box<dyn Fn(A) -> B>, ) -> Box<dyn Fn(Result<C, A>) -> Result<C, B>>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

Route the Err branch through the arrow, passing Ok through.
Source§

fn splat<A, B, C, D>( f: Self::P<A, B>, g: Self::P<C, D>, ) -> Self::P<Result<A, C>, Result<B, D>>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static, D: Clone + 'static,

+++: apply f on Ok, g on Err.
Source§

fn fanin<A, B, C>( f: Self::P<A, C>, g: Self::P<B, C>, ) -> Self::P<Result<A, B>, C>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

|||: merge two arrows, one for each branch of Result.
Source§

impl ArrowLoop for FnA

Source§

fn loop_arrow<A, B, D>(f: Box<dyn Fn((A, D)) -> (B, D)>) -> Box<dyn Fn(A) -> B>
where A: Clone + 'static, B: Clone + 'static, D: Default + Clone + 'static,

Source§

impl Braiding for FnA

Available on crate features alloc or std only.
Source§

fn braid<A, B>() -> Self::P<(A, B), (B, A)>
where A: Clone + 'static, B: Clone + 'static,

Swap the two tensor factors.
Source§

fn hexagon_forward<A, B, C>() -> Self::P<((A, B), C), (B, (C, A))>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

A simple executable form of the hexagon law.
Source§

impl Category for FnA

Source§

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

Source§

impl HKT2 for FnA

Source§

type P<A, B> = Box<dyn Fn(A) -> B>

Source§

impl Semigroupoid for FnA

Source§

fn compose<A, B, C>( f: Box<dyn Fn(B) -> C>, g: Box<dyn Fn(A) -> B>, ) -> Box<dyn Fn(A) -> C>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

Source§

impl Symmetry for FnA

Available on crate features alloc or std only.
Source§

fn symmetry<A, B>() -> Self::P<(A, B), (A, B)>
where A: Clone + 'static, B: Clone + 'static,

Source§

impl Tensor for FnA

Available on crate features alloc or std only.
Source§

fn tensor<A, B, C, D>( left: <FnA as HKT2>::P<A, B>, right: <FnA as HKT2>::P<C, D>, ) -> <FnA as HKT2>::P<(A, C), (B, D)>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static, D: Clone + 'static,

Tensor two morphisms in parallel.
Source§

fn associate<A, B, C>() -> Self::P<((A, B), C), (A, (B, C))>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

The left-associated product ((a, b), c) -> (a, (b, c)).
Source§

fn associate_inv<A, B, C>() -> Self::P<(A, (B, C)), ((A, B), C)>
where A: Clone + 'static, B: Clone + 'static, C: Clone + 'static,

The inverse associator (a, (b, c)) -> ((a, b), c).
Source§

fn left_unitor<A>() -> Self::P<((), A), A>
where A: Clone + 'static,

Left unitor ((), a) -> a.
Source§

fn left_unitor_inv<A>() -> Self::P<A, ((), A)>
where A: Clone + 'static,

Inverse left unitor a -> ((), a).
Source§

fn right_unitor<A>() -> Self::P<(A, ()), A>
where A: Clone + 'static,

Right unitor (a, ()) -> a.
Source§

fn right_unitor_inv<A>() -> Self::P<A, (A, ())>
where A: Clone + 'static,

Inverse right unitor a -> (a, ()).
Source§

impl Trace for FnA

Available on crate features alloc or std only.
Source§

fn trace<A, B, D>( morphism: <FnA as HKT2>::P<(A, D), (B, D)>, ) -> <FnA as HKT2>::P<A, B>
where A: Clone + 'static, B: Clone + 'static, D: Default + Clone + 'static,

Auto Trait Implementations§

§

impl Freeze for FnA

§

impl RefUnwindSafe for FnA

§

impl Send for FnA

§

impl Sync for FnA

§

impl Unpin for FnA

§

impl UnsafeUnpin for FnA

§

impl UnwindSafe for FnA

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.