Skip to main content

Module witherable

Module witherable 

Source
Expand description

Data structures that can be traversed and filtered simultaneously in an applicative context.

§Examples

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

let x = Some(5);
let y = wither::<OptionBrand, OptionBrand, _, _, _>(|a| Some(if a > 2 { Some(a * 2) } else { None }), x);
assert_eq!(y, Some(Some(10)));

Traits§

Witherable
A type class for data structures that can be traversed and filtered.

Functions§

wilt
Partitions a data structure based on a function that returns a Result in an applicative context.
wither
Maps a function over a data structure and filters out None results in an applicative context.