Either is a Swift Package Manager package for iOS/tvOS (11.0 and above), watchOS (5.0 and above), and macOS (10.14 and above), under Swift 5.0 and above, implementing a simple Either type, with a few built-in and useful properties and protocol conformances:
publicenumEither<LHS, RHS>{case lhs(LHS)case rhs(RHS)publicvarlhs:LHS?publicvarrhs:RHS?}extensionEither:Equatablewhere LHS:Equatable, RHS:Equatable{}extensionEither:Hashablewhere LHS:Hashable, RHS:Hashable{}extensionEither:Codablewhere LHS:Codable, RHS:Codable{ /* ... */ }
/// The comparison operator `<` does what one would expect when its operands
/// have values of the same associated type. If the operands have values of
/// different associated types, then the left hand side type, `LHS`, is always
/// considered to be lower than the right hand side type, `RHS`.
extensionEither:Comparablewhere LHS:Comparable, RHS:Comparable{ /* ... */ }Either is provided only as a Swift Package Manager package, because I'm moving away from CocoaPods and Carthage, and can be easily installed directly from Xcode.
Either is available under the MIT license. See the LICENSE file for more info.