Swift Package Index


Result suitable to Swift's untyped throws


  • The latest stable release is 0.1.0. Released 4 years ago.
  • The latest beta release is 0.2.0-beta. Released 2 years ago.
  • The last commit to master was 2 years ago.

Swift Version Compatibility

  • 0.1.0
    5.3
    5.2
    5.1
    5.0
    4.2
  • 0.2.0-beta and master
    5.3
    5.2
    5.1
    5.0
    4.2
Full build results

Platform Compatibility

  • 0.1.0
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
  • 0.2.0-beta and master
    iOS
    macOS(Intel)
    macOS(ARM)
    Linux
    tvOS
    watchOS
Full build results

ResultK

Build Status

ResultK provides Result suitable to Swift's untyped throws. ResultK's Result type does not have the second type parameter to specify the error type unlike antitypical/Result.

let a: Result<Int> = Result { try primeOrThrow(2) }
switch a {
case let .success(value):
    print(value)
case let .failure(error):
    print(error)
}

Result is a monad. map and flatMap are available for Result.

let b: Result<Int> = Result(3)
let sum: Result<Int> = a.flatMap { a in b.map { b in a + b } } // Result(5)

Installation

Swift Package Manager

Add the following to dependencies in your Package.swift.

.package(
    url: "https://github.com/koher/ResultK.git",
    from: "0.2.0-alpha"
)

Carthage

github "koher/ResultK" "master"

License

The MIT License