Using Swift’s ‘some’ keyword beyond SwiftUI
How the ‘some’ keyword can be used to create clean APIs and abstractions when using generics, even outside the realm of SwiftUI.

Articles and podcasts about Swift development, by John Sundell.

Presented by the Genius Scan SDK
How the ‘some’ keyword can be used to create clean APIs and abstractions when using generics, even outside the realm of SwiftUI.
Ben Cohen, manager of the Swift team at Apple, joins John on this WWDC22 special to discuss Swift 5.7, how generics have been made more powerful and easy to use, and how the language is expected to evolve towards Swift 6.
How Swift 5.7 makes generic protocols more powerful and easier to work with, thanks to the ‘some’ and ‘any’ keywords.
New in Swift 5.6: We can now use type placeholders to select what generic types that we want the compiler to infer. Let’s take a look at how those placeholders work, and what kinds of situations that they could be really useful in.
What abstract types are, how they could be implemented in Swift, and how they relate to protocols and other polymorphic programming techniques.
Let’s take a look at various ways to combine multiple protocols into new functionality, either by using protocol extensions, composition, or by defining dedicated types.
How Swift’s generics system enables us to create specialized extensions that only apply to types that fit certain requirements, and how that capability can be really useful.
An overview of the sort of patterns and techniques that Swift’s extensions enable us to adopt, and how extensions can turn out to be one of the most powerful features that the language has to offer.
A few different techniques that can help us share common networking logic, while also utilizing Swift’s advanced type system to make that kind of code more robust.
Let’s take a closer look at opaque return types, how they can be used both with and without SwiftUI, and how they compare to similar generic programming techniques, such as type erasure.
This week’s article is about library development, and contains a few techniques and principles that can be good to keep in mind when designing and building reusable Swift libraries.
A look at what goes into writing type- and protocol extensions that can be reused between different use cases and projects, and what sort of principles that can be good to keep in mind when doing that.
Predicates can enable us to filter various collections in ways that are incredibly flexible. Let’s take a look at how we could construct powerful, type-safe predicates using closures, generics, and operators.
Deciding whether or not to generalize a piece of code to fit more than one use case can sometimes be quite tricky. This week, let’s take a look at a few key factors that can help us strike a nice balance between being able to reuse as much of our code as possible, while also avoiding making things too complicated or ambiguous in the process.
Deploying generics in a more gentle fashion — to make a code base simpler, not more complicated.
Swift enables us to create generic types, protocols, and functions, that aren’t tied to any specific concrete type — but can instead be used with any type that meets a given set of requirements. Let’s take a look at how generics work in Swift, and how to create our own.
A situation that most Swift developers will encounter at one point or another is when some form of type erasure is needed to be able to reference a generic protocol. This week, let’s start by taking a look at what makes type erasure such an essential technique in Swift, and then explore different “flavors” of implementing it — and how each flavor comes with its own set of pros and cons.
When using syntactic sugar, what we ideally want is to be able to strike a nice balance between low verbosity and clarity, and this week, let’s take a look at a few different ways that type aliases can enable us to do just that.
Protocols continue to be an integral part of Swift, both in terms of how the language itself is designed, and also in how the standard library is structured. This week, let's take a look at how we can use protocols to create multiple levels of abstraction, and increasingly specialize them to become more and more specific to each use case.
Let’s take a look at how the Swift 4.2 compiler is able to automatically synthesize conditional conformances to the Equatable and Hashable protocols.
This week, let's take a look at Swift 4.1's new Conditional Conformances feature, and how it enables us to design code in a much more recursive fashion, making it more flexible while also reducing duplication. We'll take a look at both a simple and more advanced example, and how the standard library uses this new feature.
Using generic type constraints, we are able to add new APIs and behaviors to a type only under a certain set of constraints. This week, let's take a look at some techniques and patterns that are made possible because of type constraints, and how they can be used in practice.
How type erasure can be implemented using closures, and how it can help you work around using protocols with self or associated type requirements.