pub trait BiTraverseDispatch<'a, FnBrand, Brand: Kind_266801a817966495, A: 'a, B: 'a, C: 'a, D: 'a, F: Kind_cdc7cd43dac7585f, FA, Marker> {
// Required method
fn dispatch(
self,
fa: FA,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_266801a817966495>::Of<'a, C, D>>;
}Expand description
Trait that routes a bi_traverse operation to the appropriate type class method.
The Marker type parameter is an implementation detail resolved by
the compiler from the closures’ argument types; 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 bitraversable structure.A: The type of the first-position elements.B: The type of the second-position elements.C: The output type for first-position elements.D: The output type for second-position elements.F: The applicative functor brand for the computation.FA: The container type (owned or borrowed), inferred from the argument.Marker: Dispatch marker type, inferred automatically.
Required Methods§
Sourcefn dispatch(
self,
fa: FA,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_266801a817966495>::Of<'a, C, D>>
fn dispatch( self, fa: FA, ) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_266801a817966495>::Of<'a, C, D>>
Perform the dispatched bi_traverse operation.
§Type Signature
(self, FA) -> F (Brand C D)
§Parameters
self: The closure tuple implementing this dispatch.fa: The structure to traverse.
§Returns
The combined result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let x: Result<i32, i32> = Ok(5);
let result = bi_traverse::<RcFnBrand, ResultBrand, _, _, _, _, OptionBrand, _, _>(
(|e: i32| Some(e + 1), |s: i32| Some(s * 2)),
x,
);
assert_eq!(result, Some(Ok(10)));Implementations on Foreign Types§
Source§impl<'a, 'b, FnBrand, Brand, A, B, C, D, F, Func1, Func2> BiTraverseDispatch<'a, FnBrand, Brand, A, B, C, D, F, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (Func1, Func2)where
Brand: RefBitraversable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
C: 'a + Clone,
D: 'a + Clone,
F: Applicative,
Func1: Fn(&A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, C> + 'a,
Func2: Fn(&B) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, D> + 'a,
<Brand as Kind_266801a817966495>::Of<'a, C, D>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, C>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, D>: Clone,
Routes (Fn(&A) -> F::Of<C>, Fn(&B) -> F::Of<D>) closure tuples to RefBitraversable::ref_bi_traverse.
impl<'a, 'b, FnBrand, Brand, A, B, C, D, F, Func1, Func2> BiTraverseDispatch<'a, FnBrand, Brand, A, B, C, D, F, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (Func1, Func2)where
Brand: RefBitraversable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
C: 'a + Clone,
D: 'a + Clone,
F: Applicative,
Func1: Fn(&A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, C> + 'a,
Func2: Fn(&B) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, D> + 'a,
<Brand as Kind_266801a817966495>::Of<'a, C, D>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, C>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, D>: Clone,
Routes (Fn(&A) -> F::Of<C>, Fn(&B) -> F::Of<D>) closure tuples to RefBitraversable::ref_bi_traverse.
The FnBrand parameter is passed through to the underlying
ref_bi_traverse call.
The container must be passed by reference (&p).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The brand of the bitraversable structure.A: The first input type.B: The second input type.C: The first output type.D: The second output type.F: The applicative functor brand.Func1: The first closure type.Func2: The second closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_266801a817966495>::Of<'a, C, D>>
fn dispatch( self, fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, ) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_266801a817966495>::Of<'a, C, D>>
§Type Signature
forall Brand A B C D F. (RefBitraversable Brand, LiftFn FnBrand, Applicative F) => ((&A -> F C, &B -> F D), &Brand A B) -> F (Brand C D)
§Parameters
self: The closure tuple.fa: A reference to the structure to traverse.
§Returns
The combined result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let x: Result<i32, i32> = Ok(5);
let result = bi_traverse::<RcFnBrand, ResultBrand, _, _, _, _, OptionBrand, _, _>(
(|e: &i32| Some(e + 1), |s: &i32| Some(s * 2)),
&x,
);
assert_eq!(result, Some(Ok(10)));Source§impl<'a, FnBrand, Brand, A, B, C, D, F, Func1, Func2> BiTraverseDispatch<'a, FnBrand, Brand, A, B, C, D, F, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (Func1, Func2)where
Brand: Bitraversable,
A: 'a + Clone,
B: 'a + Clone,
C: 'a + Clone,
D: 'a + Clone,
F: Applicative,
Func1: Fn(A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, C> + 'a,
Func2: Fn(B) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, D> + 'a,
Routes (Fn(A) -> F::Of<C>, Fn(B) -> F::Of<D>) closure tuples to Bitraversable::bi_traverse.
impl<'a, FnBrand, Brand, A, B, C, D, F, Func1, Func2> BiTraverseDispatch<'a, FnBrand, Brand, A, B, C, D, F, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (Func1, Func2)where
Brand: Bitraversable,
A: 'a + Clone,
B: 'a + Clone,
C: 'a + Clone,
D: 'a + Clone,
F: Applicative,
Func1: Fn(A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, C> + 'a,
Func2: Fn(B) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, D> + 'a,
Routes (Fn(A) -> F::Of<C>, Fn(B) -> F::Of<D>) closure tuples to Bitraversable::bi_traverse.
The FnBrand parameter is unused by the Val path but is accepted for
uniformity with the Ref path.
§Type Parameters
'a: The lifetime of the values.FnBrand: The cloneable function brand (unused by Val path).Brand: The brand of the bitraversable structure.A: The first input type.B: The second input type.C: The first output type.D: The second output type.F: The applicative functor brand.Func1: The first closure type.Func2: The second closure type.
Source§fn dispatch(
self,
fa: <Brand as Kind_266801a817966495>::Of<'a, A, B>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_266801a817966495>::Of<'a, C, D>>
fn dispatch( self, fa: <Brand as Kind_266801a817966495>::Of<'a, A, B>, ) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_266801a817966495>::Of<'a, C, D>>
§Type Signature
forall Brand A B C D F. (Bitraversable Brand, Applicative F) => ((A -> F C, B -> F D), Brand A B) -> F (Brand C D)
§Parameters
self: The closure tuple.fa: The structure to traverse.
§Returns
The combined result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let x: Result<i32, i32> = Ok(5);
let result = bi_traverse::<RcFnBrand, ResultBrand, _, _, _, _, OptionBrand, _, _>(
(|e: i32| Some(e + 1), |s: i32| Some(s * 2)),
x,
);
assert_eq!(result, Some(Ok(10)));