Skip to content

koher/ResultK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Result suitable to Swift's untyped throws

Resources

License

Stars

Watchers

Forks

Packages

No packages published