_Fallible

public protocol _Fallible : CustomStringConvertible

Internal use only The combination of protocol _Fallible and enum Fallible is a dirty hack of type system. But there are no higher kinded types or generic protocols to implement it properly. Major propose is an ability to implement flatten() method.

  • a type of a successful case value

    Declaration

    Swift

    associatedtype Success
  • returns success value if _Fallible contains one

    Declaration

    Swift

    var success: Success? { get }
  • returns success if Fallible has a success value inside. Crashes otherwise

    Declaration

    Swift

    var unsafeSuccess: Success! { get }
  • returns failure value if _Fallible contains one

    Declaration

    Swift

    var failure: Swift.Error? { get }
  • initializes fallible with success value

    Declaration

    Swift

    init(success: Success)
  • initializes fallible with failure value

    Declaration

    Swift

    init(failure: Swift.Error)
  • executes handler if the fallible containse success value

    Declaration

    Swift

    func onSuccess(_ handler: (Success) throws -> Void) rethrows
  • executes handler if the fallible containse failure value

    Declaration

    Swift

    func onFailure(_ handler: (Swift.Error) throws -> Void) rethrows
  • (success or failure) * (try transform success to success) -> (success or failure)

    Declaration

    Swift

    func map<T>(_ transform: (Success) throws -> T) -> Fallible<T>
  • (success or failure) * (try transform success to (success or failure)) -> (success or failure)

    Declaration

    Swift

    func flatMap<T>(_ transform: (Success) throws -> Fallible<T>) -> Fallible<T>
  • (success or failure) * (try transform failure to success) -> (success or failure)

    Declaration

    Swift

    func tryRecover(_ transform: (Swift.Error) throws -> Success) -> Fallible<Success>
  • (success or failure) * (transform failure to success) -> success

    Declaration

    Swift

    func recover(_ transform: (Swift.Error) -> Success) -> Success
  • returns success or throws failure

    Declaration

    Swift

    func liftSuccess() throws -> Success