arrow-mtl / arrow.mtl.typeclasses / TraverseFilter

TraverseFilter

interface TraverseFilter<F> : Traverse<F>, FunctorFilter<F>

Functions

filter open fun <A> Kind<F, A>.filter(f: (A) -> Boolean): Kind<F, A>
Apply a filter to a structure such that the output structure contains all A elements in the input structure that satisfy the predicate f but none that don’t.
filterA open fun <G, A> Kind<F, A>.filterA(f: (A) -> Kind<G, Boolean>, GA: Applicative<G>): Kind<G, Kind<F, A>>
mapFilter open fun <A, B> Kind<F, A>.mapFilter(f: (A) -> Option<B>): Kind<F, B>
A combined map and filter. Filtering is handled via Option instead of Boolean such that the output type B can be different than the input type A.
traverseFilter abstract fun <G, A, B> Kind<F, A>.traverseFilter(AP: Applicative<G>, f: (A) -> Kind<G, Option<B>>): Kind<G, Kind<F, B>>

Inherited Functions

collect open fun <A, B> Kind<F, A>.collect(f: PartialFunction<A, B>): Kind<F, B>
Similar to mapFilter but uses a partial function instead of a function that returns an Option.
flattenOption open fun <A> Kind<F, Option<A>>.flattenOption(): Kind<F, A>
“Flatten” out a structure by collapsing Options.

Inheritors

ComposedTraverseFilter interface ComposedTraverseFilter<F, G> : TraverseFilter<Nested<F, G>>, ComposedTraverse<F, G>
ConstTraverseFilter interface ConstTraverseFilter<X> : TraverseFilter<ConstPartialOf<X>>, ConstTraverse<X>
OptionTTraverseFilter interface OptionTTraverseFilter<F> : TraverseFilter<OptionTPartialOf<F>>, OptionTTraverse<F>
OptionTraverseFilter interface OptionTraverseFilter : TraverseFilter<ForOption>

Type Class Hierarchy