Skip to main content

Module traversable

Module traversable 

Source
Expand description

Data structures that can be traversed, accumulating results in an applicative context.

§Examples

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

let x = Some(5);
let y = traverse::<OptionBrand, _, _, OptionBrand, _>(|a| Some(a * 2), x);
assert_eq!(y, Some(Some(10)));

Traits§

Traversable
A type class for traversable functors.

Functions§

sequence
Evaluate each computation in a Traversable structure and accumulate the results into an Applicative context.
traverse
Map each element of the Traversable structure to a computation, evaluate those computations and combine the results into an Applicative context.