Created
August 3, 2018 01:24
-
-
Save mdiep/b4481a38a4b5ec48ec7ba8fb9e3ad229 to your computer and use it in GitHub Desktop.
Swift Tuple Wat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct S<Args, Return> {} | |
infix operator ~ | |
func ~ <A, T>(lhs: (A) -> T, rhs: String) -> S<(A), T> { | |
return S() | |
} | |
func ~ <A, B, T>(lhs: (A, B) -> T, rhs: String) -> S<(A, B), T> { | |
return S() | |
} | |
func f(_: Int, _: Int) -> Int { return 0 } | |
// Swift can't tell which `~` to use. That makes some sense. | |
_ = f ~ "" | |
// But this is also ambiguous: | |
let _: S<(Int, Int), Int> = f ~ "" | |
// However, more than one set of parens will disambiguate: | |
let _: S<((((Int, Int)))), Int> = f ~ "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment