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

    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

    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

    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.

  • fromOption(_:_:) Extension method

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

    Declaration

    Swift

    static func fromOption<A>(_ oa: Option<A>, _ f: () -> E) -> Kind<Self, A>

    Parameters

    oa

    An Option value.

    f

    A function providing the error value in case the option is empty.

    Return Value

    A value in the context implementing this instance.

  • fromTry(_:_:) Extension method

    Converts a Try value into a value in the context implementing this instance.

    Declaration

    Swift

    static func fromTry<A>(_ ta: Try<A>, _ f: (Error) -> E) -> Kind<Self, A>

    Parameters

    ta

    A Try value.

    f

    A function transforming the error contained in Try to the error type of this instance.

    Return Value

    A value in the context implementing this instance.

  • catchError(_:_:) Extension method

    Evaluates a throwing function, catching and mapping errors.

    Declaration

    Swift

    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

    static func catchError<A>(_ f: () throws -> A) -> Kind<Self, A> where Self.E == Error

    Parameters

    f

    A throwing function.

    Return Value

    A value in the context implementing this instance.