sequence

Function sequence 

Source
pub fn sequence<'a, Brand: Traversable, F: Applicative, A: 'a + Clone>(
    ta: Apply1L1T<'a, Brand, Apply1L1T<'a, F, A>>,
) -> Apply1L1T<'a, F, Apply1L1T<'a, Brand, A>>
where Apply1L1T<'a, F, A>: Clone, Apply1L1T<'a, Brand, A>: Clone,
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.

§Type Signature

forall a f. (Traversable t, Applicative f) => (t (f a)) -> f (t a)

§Parameters

  • ta: The traversable structure containing values in an applicative context.

§Returns

The traversable structure wrapped in the applicative context.

§Examples

use fp_library::classes::traversable::sequence;
use fp_library::brands::OptionBrand;

let x = Some(Some(5));
let y = sequence::<OptionBrand, OptionBrand, _>(x);
assert_eq!(y, Some(Some(5)));