[swift-evolution] Feasibility of "T1 & ¬T2"
Dave DeLong
swift at davedelong.com
Wed Nov 29 21:27:33 CST 2017
Hi SE,
I’m pondering some esoteric type stuff as I’m sketching out an improved date/time library (https://github.com/davedelong/Chronology <https://github.com/davedelong/Chronology>), and I’m wondering two things:
1️⃣ Is there a way to express a type that does *not* conform to a protocol?
For example, let’s say I have three protocols:
protocol YearHaving { var year: Int }
protocol MonthHaving { var month: Int }
protocol DayHaving { var day: Int }
typealias DateHaving = YearHaving & MonthHaving & DayHaving
Now, I want to allow for some adjustments to values that have these types:
extension DayHaving {
func removingDay() → Self & ¬DayHaving // whatever type “self” is, except it does not conform to “DayHaving”, because you just removed the day value
}
Is this possible?
2️⃣ If this is not possible, would it be hard to add something like this in?
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171129/ec9c547d/attachment.html>
More information about the swift-evolution
mailing list