Skip to content

Instantly share code, notes, and snippets.

@oisdk
Created September 28, 2015 11:40
Show Gist options
  • Save oisdk/53d5ed908a5f3edd3668 to your computer and use it in GitHub Desktop.
Save oisdk/53d5ed908a5f3edd3668 to your computer and use it in GitHub Desktop.
protocol Bit {}
protocol IsSet {}
protocol IsClr {}
struct Set : Bit, IsSet {}
struct Clr : Bit, IsClr {}
protocol Op { typealias Result }
extension Op { typealias Result = Set }
struct Nand<B0: Bit, B1: Bit> : Op {}
extension Nand where B0: IsSet, B1: IsSet {
typealias Result = Clr
}
struct Not<B: Bit> {}
extension Not where B: IsSet {
typealias Result = Clr
}
struct And<B0: Bit, B1: Bit> {
typealias Result = Not<Nand<B0, B1>.Result>.Result
}
// ambiguous type name 'Result' in 'Nand<B0, B1>'
Nand<Clr, Clr>.Result.self
Nand<Clr, Set>.Result.self
Nand<Set, Clr>.Result.self
Nand<Set, Set>.Result.self
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment