With special guest Luke Redpath, this series is an exploration of protocol witnesses and how we can use them to bend Codable to behave in different ways. This series explores Swift's generics, functional composition, and expressive API design.
Length: about 2 hours
In the next few episodes we will explore the concept of Protocol Witnesses. This is an advanced topic that can be somewhat hard to approach, but in learning about Protocol Witnesses you will see how we can leverage the Swift language and functional programming to do some really cool things.
We start exploring the concept of converting Encodable into an Encoding protocol witness. We discover how to clean up our code and make it fit in with `JSONEncoder`’s existing API. We then break down our example into smaller pieces and discuss how we can leverage pullback and functional composition to build bigger pieces out of smaller ones.
Last time we talked about the Encodable protocol. This time let's look at the Decodable protocol. We explore the general concept, then introduce zip and map as utilities to compose smaller decodings into larger ones.
In this episode we introduce a new open source library called Swift Coding that takes all of these concepts and wraps it up into a Swift Package you can use in your own projects. We give a tour of what the library can do and how you can use it.