pub struct ProfunctorSecondAppliedBrand<Brand, B>(/* private fields */);Expand description
An adapter that partially applies a Profunctor to its second argument, creating a Contravariant functor.
§Examples
use fp_library::{
brands::*,
classes::contravariant::contramap,
};
let f = |x: i32| x > 5;
let is_long_int = contramap::<ProfunctorSecondAppliedBrand<RcFnBrand, bool>, _, _>(
|s: String| s.len() as i32,
std::rc::Rc::new(f) as std::rc::Rc<dyn Fn(i32) -> bool>,
);
assert_eq!(is_long_int("123456".to_string()), true);
assert_eq!(is_long_int("123".to_string()), false);Trait Implementations§
Source§impl<Brand: Clone, B: Clone> Clone for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand: Clone, B: Clone> Clone for ProfunctorSecondAppliedBrand<Brand, B>
Source§fn clone(&self) -> ProfunctorSecondAppliedBrand<Brand, B>
fn clone(&self) -> ProfunctorSecondAppliedBrand<Brand, B>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<Brand: Profunctor, B: 'static> Contravariant for ProfunctorSecondAppliedBrand<Brand, B>
Contravariant instance for ProfunctorSecondAppliedBrand.
impl<Brand: Profunctor, B: 'static> Contravariant for ProfunctorSecondAppliedBrand<Brand, B>
Contravariant instance for ProfunctorSecondAppliedBrand.
Contramaps over the first (contravariant) type parameter of a profunctor via Profunctor::map_input.
§Type Parameters
Brand: The profunctor brand.B: The fixed second type parameter.
Source§fn contramap<'a, A: 'a, C: 'a>(
f: impl Fn(C) -> A + 'a,
fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, C>
fn contramap<'a, A: 'a, C: 'a>( f: impl Fn(C) -> A + 'a, fa: <Self as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Self as Kind_cdc7cd43dac7585f>::Of<'a, C>
Contramap a function over the contravariant type parameter.
§Type Signature
forall Brand B A C. Profunctor Brand => (C -> A, ProfunctorSecondApplied Brand B A) -> ProfunctorSecondApplied Brand B C
§Type Parameters
'a: The lifetime of the values.A: The input type.C: The output type.
§Parameters
f: The function to apply.fa: The profunctor value to contramap over.
§Returns
The contramapped profunctor value.
§Examples
use fp_library::{
brands::*,
functions::explicit::contramap,
};
let f = std::rc::Rc::new(|x: i32| x + 1) as std::rc::Rc<dyn Fn(i32) -> i32>;
let g =
contramap::<ProfunctorSecondAppliedBrand<RcFnBrand, i32>, _, _, _, _>(|x: i32| x * 2, f);
assert_eq!(g(5), 11); // (5 * 2) + 1Source§impl<Brand: Profunctor, B: 'static> Kind_cdc7cd43dac7585f for ProfunctorSecondAppliedBrand<Brand, B>
Generated implementation of Kind_cdc7cd43dac7585f for ProfunctorSecondAppliedBrand < Brand, B >.
impl<Brand: Profunctor, B: 'static> Kind_cdc7cd43dac7585f for ProfunctorSecondAppliedBrand<Brand, B>
Generated implementation of Kind_cdc7cd43dac7585f for ProfunctorSecondAppliedBrand < Brand, B >.
Source§type Of<'a, A: 'a> = <Brand as Kind_266801a817966495>::Of<'a, A, B>
type Of<'a, A: 'a> = <Brand as Kind_266801a817966495>::Of<'a, A, B>
The applied type.
Source§impl<Brand: Ord, B: Ord> Ord for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand: Ord, B: Ord> Ord for ProfunctorSecondAppliedBrand<Brand, B>
Source§fn cmp(&self, other: &ProfunctorSecondAppliedBrand<Brand, B>) -> Ordering
fn cmp(&self, other: &ProfunctorSecondAppliedBrand<Brand, B>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<Brand: PartialEq, B: PartialEq> PartialEq for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand: PartialEq, B: PartialEq> PartialEq for ProfunctorSecondAppliedBrand<Brand, B>
Source§fn eq(&self, other: &ProfunctorSecondAppliedBrand<Brand, B>) -> bool
fn eq(&self, other: &ProfunctorSecondAppliedBrand<Brand, B>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<Brand: PartialOrd, B: PartialOrd> PartialOrd for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand: PartialOrd, B: PartialOrd> PartialOrd for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand: Copy, B: Copy> Copy for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand: Eq, B: Eq> Eq for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand, B> StructuralPartialEq for ProfunctorSecondAppliedBrand<Brand, B>
Auto Trait Implementations§
impl<Brand, B> Freeze for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand, B> RefUnwindSafe for ProfunctorSecondAppliedBrand<Brand, B>where
Brand: RefUnwindSafe,
B: RefUnwindSafe,
impl<Brand, B> Send for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand, B> Sync for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand, B> Unpin for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand, B> UnsafeUnpin for ProfunctorSecondAppliedBrand<Brand, B>
impl<Brand, B> UnwindSafe for ProfunctorSecondAppliedBrand<Brand, B>where
Brand: UnwindSafe,
B: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more