pub trait Applicative:
Pointed
+ Semiapplicative
+ ApplyFirst
+ ApplySecond { }Expand description
A type class for applicative functors, allowing for values to be wrapped in a context and for functions within a context to be applied to values within a context.
§Type Signature
class (Pointed f, Semiapplicative f) => Applicative f
§Examples
use fp_library::{brands::*, classes::*, functions::*};
// Applicative combines Pointed (pure) and Semiapplicative (apply)
let f = pure::<OptionBrand, _>(cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2));
let x = pure::<OptionBrand, _>(5);
let y = apply::<RcFnBrand, OptionBrand, _, _>(f, x);
assert_eq!(y, Some(10));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.