Either is an implementation of Haskell's Either
type in Swift. The current
version (1.x) is compatible with Swift 3.
Either is an enum consisting of either a .right or a .left, each with an associated value. It's commonly used in Haskell for error handling, with Right holding a success value and Left holding a failure value. This is a more functional way of handling errors compared to throwing and catching.
The best way to see this library in action is by looking at the tests. Each function is also commented upon in the Either source.
Add the following to your Cartfile:
github "runkmc/either"
Then run carthage update
.
Add the following to your Podfile:
pod 'Either'
You will also need to make sure you're opting into using frameworks:
use_frameworks!
Then run pod install
.
Kevin McGladdery, [email protected]
Either is available under the MIT license. See the LICENSE file for more info.