TraverseFilter

public protocol TraverseFilter : FunctorFilter, Traverse

TraverseFilter represents array-like structures that can be traversed and filtered as a single combined operation. It provides the same capabilities as Traverse and FunctorFilter together.

  • A combined traverse and filter operation. Filtering is handled using Option instead of Bool so that the output can be different than the input type.

    Declaration

    Swift

    static func traverseFilter<A, B, G: Applicative>(_ fa: Kind<Self, A>, _ f: @escaping (A) -> Kind<G, OptionOf<B>>) -> Kind<G, Kind<Self, B>>

    Parameters

    fa

    A value in the context implementing this instance.

    f

    A function to traverse and filter each value.

    Return Value

    Result of traversing this structure and filter values using the provided function.

  • filterA(_:_:) Extension method

    Filters values in a different context.

    Declaration

    Swift

    public static func filterA<A, G: Applicative>(_ fa: Kind<Self, A>, _ f: @escaping (A) -> Kind<G, Bool>) -> Kind<G, Kind<Self, A>>

    Parameters

    fa

    A value in the context implementing this instance.

    f

    A function to filter each value.

    Return Value

    Result of traversing this structure and filter values using the provided function.

  • filter(_:_:) Extension method

    Filters values using a predicate.

    Declaration

    Swift

    public static func filter<A>(_ fa: Kind<Self, A>, _ f: @escaping (A) -> Bool) -> Kind<Self, A>

    Parameters

    fa

    A value in the context implementing this instance.

    f

    A boolean predicate.

    Return Value

    Result of traversing this structure and filter values using the provided function.