FunctorFilter

public protocol FunctorFilter : Functor

A FunctorFilter provides the same capabilities as a Functor, while filtering out elements simultaneously.

  • Maps the value/s in the context implementing this instance, filtering out the ones resulting in Option.none.

    Declaration

    Swift

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

    Parameters

    fa

    A value in the context implementing this instance.

    f

    A function to map objects and filter them out.

    Return Value

    Transformed and filtered values, in the context implementing this instance.

  • flattenOption(_:) Extension method

    Removes the Option.none value/s in this context and extracts the Option.some ones.

    Declaration

    Swift

    static func flattenOption<A>(_ fa: Kind<Self, OptionOf<A>>) -> Kind<Self, A>

    Parameters

    fa

    Optional values in the context implementing this instance.

    Return Value

    Plain values in the context implementing this instance.

  • filter(_:_:) Extension method

    Filters out the value/s in the context implementing this instance that do not match the given predicate.

    Declaration

    Swift

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

    Parameters

    fa

    Value in the context implementing this instance.

    f

    Filtering predicate.

    Return Value

    Filtered value in the context implementing this instance.