filter

fun <A> filter(predicate: (A) -> Boolean): OptionalGetter<A, A>(source)

OptionalGetter to itself if it satisfies the predicate.

Select all the elements which satisfy the predicate.

import arrow.optics.Traversal
import arrow.optics.Optional

val positiveNumbers = Traversal.list<Int>() compose OptionalGetter.filter { it >= 0 }

positiveNumbers.getAll(listOf(1, 2, -3, 4, -5)) == listOf(1, 2, 4)