Found 5 bookmarks
Newest
The Littlest Type
The Littlest Type
In type theory, an uninhabited type is often called a bottom type, and written as ⊥. A bottom type is a subtype of every other type. So `Never` would be an `Int` and a `String` and a `UIViewController` and every other type. The opposite is the top type (⊤), the supertype of every other type. In Swift, that’s `Any`.
·robnapier.net·
The Littlest Type
Protocols III: Existential Spelling
Protocols III: Existential Spelling
Existentials and universals are [logical] “duals,” which means that one can be transformed into the other without losing its structure. So `AnySequence` is a universal type (generic) that’s equivalent to an explicit existential of `Sequence` (protocol). That’s why when you run into problems with protocols, your solution may be to convert it into generic structs (or vice versa). They solve the same problems in different ways with different trade-offs. And when you see “can only be used as a generic constraint,” what the compiler is really telling you is that protocols with associated types (PATs) don’t have an existential.
·robnapier.net·
Protocols III: Existential Spelling
Rob Napier’s Swift/Haskell post
Rob Napier’s Swift/Haskell post
A paradigm is sneaking in when you aren’t paying attention. Pay attention. There’s a chance here to influence development practice for decades ​ We really can have languages that give the benefits of tomorrow without losing all the working components of today. I think Swift can be one of those languages. ​ Much of that, I believe, is education.
·robnapier.net·
Rob Napier’s Swift/Haskell post