ApplicativeError

public protocol ApplicativeError : Applicative

An ApplicativeError is an Applicative that has capabilities to raise and handle error values.

It has an associated type E to represent the error type that the implementing instance is able to handle.

  • Error type associated to this ApplicativeError instance

    Declaration

    Swift

    associatedtype E
  • Lifts an error to the context implementing this instance.

    Declaration

    Swift

    static func raiseError<A>(_ e: E) -> Kind<Self, A>

    Parameters

    e

    A value of the error type.

    Return Value

    A value representing the error in the context implementing this instance.

  • Handles an error, potentially recovering from it by mapping it to a value in the context implementing this instance.

    Declaration

    Swift

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

    Parameters

    fa

    A computation that may have an error.

    f

    A recovery function.

    Return Value

    A value where the possible errors have been recovered using the provided function.

  • handleError(_:_:) Extension method

    Handles an error, potentially recovering from it by mapping it to a value.

    Declaration

    Swift

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

    Parameters

    fa

    A computation that may have an error.

    f

    A recovery function.

    Return Value

    A value where the possible errors have been recovered using the provided function.

  • attempt(_:) Extension method

    Handles errors by converting them into Either values in the context implementing this instance.

    Declaration

    Swift

    public static func attempt<A>(_ fa: Kind<Self, A>) -> Kind<Self, Either<E, A>>

    Parameters

    fa

    A computation that may have an error.

    Return Value

    An either wrapped in the context implementing this instance.

  • fromEither(_:) Extension method

    Converts an Either value into a value in the context implementing this instance.

    Declaration

    Swift

    public static func fromEither<A>(_ fea: Either<E, A>) -> Kind<Self, A>

    Parameters

    fea

    An Either value.

    Return Value

    A value in the context implementing this instance.

  • catchError(_:_:) Extension method

    Evaluates a throwing function, catching and mapping errors.

    Declaration

    Swift

    public static func catchError<A>(_ f: () throws -> A, _ recover: (Error) -> E) -> Kind<Self, A>

    Parameters

    f

    A throwing function.

    recover

    A function that maps from Error to the type that this instance is able to handle.

    Return Value

    A value in the context implementing this instance.

  • catchError(_:) Extension method

    Evaluates a throwing function, catching errors.

    Declaration

    Swift

    public static func catchError<A>(_ f: () throws -> A) -> Kind<Self, A>

    Parameters

    f

    A throwing function.

    Return Value

    A value in the context implementing this instance.