Trait Apply

Source
pub trait Apply {
    // Required method
    fn apply<F, A, B>(
        ff: App<Self, (F,)>,
    ) -> impl Fn(App<Self, (A,)>) -> App<Self, (B,)>
       where Self: Kind<(F,)> + Kind<(A,)> + Kind<(B,)>,
             App<Self, (F,)>: Clone,
             F: Fn(A) -> B,
             A: Clone;
}
Expand description

A typeclass for types that support function application within a context.

Apply provides the ability to apply functions that are themselves wrapped in a context to values that are also wrapped in a context. This allows for sequencing computations where both the function and the value are in a context.

§Laws

Apply instances must satisfy the following law:

  • Composition: apply(apply(f)(g))(x) = apply(f)(apply(g)(x)).

Required Methods§

Source

fn apply<F, A, B>( ff: App<Self, (F,)>, ) -> impl Fn(App<Self, (A,)>) -> App<Self, (B,)>
where Self: Kind<(F,)> + Kind<(A,)> + Kind<(B,)>, App<Self, (F,)>: Clone, F: Fn(A) -> B, A: Clone,

Applies a function within a context to a value within a context.

§Type Signature

forall f a b. Apply f => f (a -> b) -> f a -> f b

§Parameters
  • ff: A function wrapped in the context.
§Returns

A function that takes a value wrapped in the context and returns the result of applying the function to the value, both within the context.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§