ResultK

master

Result suitable to Swift's untyped throws
koher/ResultK

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

Description

  • Swift Tools 4.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Apr 05 2024 06:54:26 GMT-0900 (Hawaii-Aleutian Daylight Time)