pub trait WitherDispatch<'a, FnBrand, Brand: Kind_cdc7cd43dac7585f, M: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, FA, Marker> {
// Required method
fn dispatch(
self,
ta: FA,
) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>;
}Expand description
Trait that routes a wither operation to the appropriate type class method.
The Marker type parameter is an implementation detail resolved by
the compiler from the closure’s argument type; callers never specify
it directly. The FA type parameter is inferred from the container
argument: owned for Val dispatch, borrowed for Ref dispatch.
§Type Parameters
'a: The lifetime of the values.FnBrand: The brand of the cloneable function to use.Brand: The brand of the witherable structure.M: The applicative functor brand for the computation.A: The type of the elements in the input structure.B: The type of the elements in the output structure.FA: The container type (owned or borrowed), inferred from the argument.Marker: Dispatch marker type, inferred automatically. EitherValorRef.
Required Methods§
Sourcefn dispatch(
self,
ta: FA,
) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
fn dispatch( self, ta: FA, ) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
Perform the dispatched wither operation.
§Type Signature
(self, FA) -> M (Brand B)
§Parameters
self: The closure implementing this dispatch.ta: The structure to filter.
§Returns
The filtered result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = wither::<RcFnBrand, OptionBrand, OptionBrand, _, _, _, _>(
|a: i32| Some(if a > 2 { Some(a * 2) } else { None }),
Some(5),
);
assert_eq!(result, Some(Some(10)));Implementors§
impl<'a, 'b, FnBrand, Brand, M, A, B, Func> WitherDispatch<'a, FnBrand, Brand, M, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Funcwhere
Brand: RefWitherable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
M: Applicative,
Func: Fn(&A) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>>: Clone,
<M as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>>: Clone,
Routes Fn(&A) -> M::Of<Option<B>> closures to RefWitherable::ref_wither.
The container must be passed by reference (&ta).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The brand of the witherable structure.M: The applicative functor brand.A: The type of the elements in the input structure.B: The type of the elements in the output structure.Func: The closure type.
impl<'a, FnBrand, Brand, M, A, B, Func> WitherDispatch<'a, FnBrand, Brand, M, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Funcwhere
Brand: Witherable,
A: 'a + Clone,
B: 'a + Clone,
M: Applicative,
Func: Fn(A) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>>: Clone,
<M as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>>: Clone,
Routes Fn(A) -> M::Of<Option<B>> closures to Witherable::wither.
§Type Parameters
'a: The lifetime of the values.FnBrand: The cloneable function brand (unused by Val path).Brand: The brand of the witherable structure.M: The applicative functor brand.A: The type of the elements in the input structure.B: The type of the elements in the output structure.Func: The closure type.