Skip to content

wltrup/Either

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Either

Xcode Swift GitHub tag (latest SemVer) GitHub

What

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:

public enum Either<LHS, RHS> {
    
    case lhs(LHS)
    case rhs(RHS)
    
    public var lhs: LHS?
    public var rhs: RHS?
    
}

extension Either: Equatable where LHS: Equatable, RHS: Equatable {}
extension Either: Hashable where LHS: Hashable, RHS: Hashable {}
extension Either: Codable where 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`.
extension Either: Comparable where LHS: Comparable, RHS: Comparable { /* ... */ }

Installation

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.

License

Either is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages