Unlock This Episode
Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.
We think this generated file is just a stopgap until Swift gains the full power of variadic generics, but either way, it got us wondering whether generated source code would be a good fit for our parser library, and then we could just rip them out once variadic generics arrive in Swift. We were most worried about compile times, but we do know that the Swift compiler team has greatly improved the performance of result builders. Our early experiments were extremely promising, so we went all in and we think it is the future of the library.
Before diving in, let’s first discuss result builders from first principles so that we all know how to leverage them to their full potential, and then we will see how these ideas apply to parsers. We will show that result builders go far beyond just simple ergonomics for our parsing library. They unlock all new forms of APIs that can be really, really powerful.
So, let’s get started.
Subscribe to Point-Free
Access this episode, plus all past and future episodes when you become a subscriber.
Already a subscriber? Log in
Collection: ParsingBrandon Williams & Stephen Celis
Parsing is a surprisingly ubiquitous problem in programming. Every time we construct an integer or a URL from a string, we are technically doing parsing. After demonstrating the many types of parsing that Apple gives us access to, we will take a step back and define the essence of parsing in a single type. That type supports many wonderful types of compositions, and allows us to break large, complex parsing problems into small, understandable units.
Swift ParsingBrandon Williams & Stephen Celis • Tuesday Dec 21, 2021
A library for turning nebulous data into well-structured data, with a focus on composition, performance, generality, and invertibility.
Declarative String ProcessingAlex Alonso, Nate Cook, Michael Ilseman, Kyle Macomber, Becca Royal-Gordon, Tim Vermeulen, and Richard Wei • Wednesday Sep 29, 2021
The Swift core team’s proposal and experimental repository for declarative string processing, which includes result builder syntax for creating regular expressions, and inspired us to explore result builders for parsing.