pub fn sequence<'a, ClonableFnBrand: 'a + ClonableFn, Brand: Traversable, F: Applicative, A: 'a + Clone>(
t: Apply0L1T<Brand, Apply0L1T<F, A>>,
) -> Apply0L1T<F, Apply0L1T<Brand, A>>Expand description
Evaluate each computation in a Traversable structure and accumulate the results into an Applicative context.
Free function version that dispatches to the type class’ associated function.
The default implementation of sequence is implemented in terms of traverse and identity where:
sequence = traverse identity
§Type Signature
forall a. Traversable t, Applicative f => t (f a) -> f (t a)
§Parameters
t: ATraversablestructure containingApplicativecomputations.
§Returns
An Applicative containing the accumulated results of the computations.
§Examples
use fp_library::{brands::{VecBrand, OptionBrand, RcFnBrand}, functions::sequence};
use std::rc::Rc;
assert_eq!(
sequence::<RcFnBrand, VecBrand, OptionBrand, i32>(vec![Some(1), Some(2), Some(3)]),
Some(vec![1, 2, 3])
);