arrow-mtl / arrow.mtl.typeclasses / FunctorFilter


interface FunctorFilter<F> : Functor<F>

A Functor with the ability to mapFilter. Enables collect based on PartialFunction predicates.


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.
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.
flattenOption open fun <A> Kind<F, Option<A>>.flattenOption(): Kind<F, A>
“Flatten” out a structure by collapsing Options.
mapFilter abstract 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.


ComposedFunctorFilter interface ComposedFunctorFilter<F, G> : FunctorFilter<Nested<F, G>>, ComposedFunctor<F, G>
ListKFunctorFilter interface ListKFunctorFilter : FunctorFilter<ForListK>
MonadFilter interface MonadFilter<F> : Monad<F>, FunctorFilter<F>
NonEmptyListFunctorFilter interface NonEmptyListFunctorFilter : FunctorFilter<ForNonEmptyList>
OptionFunctorFilter interface OptionFunctorFilter : FunctorFilter<ForOption>
OptionTFunctorFilter interface OptionTFunctorFilter<F> : FunctorFilter<OptionTPartialOf<F>>, OptionTFunctor<F>
SequenceKFunctorFilter interface SequenceKFunctorFilter : FunctorFilter<ForSequenceK>
TraverseFilter interface TraverseFilter<F> : Traverse<F>, FunctorFilter<F>
TryFunctorFilter interface TryFunctorFilter : FunctorFilter<ForTry>

Type Class Hierarchy