Skip to main content

sequence

Function sequence 

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

§Type Parameters

  • Brand: The brand of the traversable structure.
  • F: The applicative context.
  • A: The type of the elements in the traversable structure.

§Parameters

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

§Returns

The traversable structure wrapped in the applicative context.

§Examples

use fp_library::{functions::*, brands::*};

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