🎉 End-of-year Sale! Save 25% when you subscribe today.

Parser Builders: The Problem

Episode #173 • Jan 10, 2022 • Subscriber-Only

Let’s revisit a favorite topic: parsing! After a short recap, we will theorize and motivate the addition of result builder syntax to our parsing library, which will help unlock a new level of ergonomics and API design.

Previous episode
Parser Builders: The Problem
Next episode
Locked

Unlock This Episode

Our Free plan includes 1 subscriber-only episode of your choice, plus weekly updates from our newsletter.

Sign in with GitHub

Introduction

It has been over a year since we last talked about parsers on Point-Free, and it was more than one year before that since we first introduced the idea of parsers. There’s still so much we want to discuss when it comes to parsing, and so we are reviving the topic this week to explore some really exciting advancements we’ve made recently.

The last time we talked about parsing we heavily focused on:

  • Generalization, which allows parsers to process any type of input into any type of output;

  • Ergonomics, which allows us to construct parsers in the most fluent way possible; and

  • Performance, which allows our parsers to be as performant as ad-hoc, hand-rolled parsers, and sometimes even more performant.

Starting this week we are going to continue a bit more with the ergonomics angle of parsing by seeing what Swift’s result builders have to offer parsing. Result builders are a relatively new feature of Swift that were primarily created in order to facilitate a concise syntax for SwiftUI views, but there are many applications for builders.

Parser recap


References

  • Collection: Parsing
    Brandon Williams & Stephen Celis
    Note

    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 Parsing
    Brandon Williams & Stephen Celis • Dec 21, 2021

    A library for turning nebulous data into well-structured data, with a focus on composition, performance, generality, and invertibility.

  • Declarative String Processing
    Alex Alonso, Nate Cook, Michael Ilseman, Kyle Macomber, Becca Royal-Gordon, Tim Vermeulen, and Richard Wei • 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.

  • The Many Faces of Map
    Brandon Williams & Stephen Celis • Apr 23, 2018
    Note

    Why does the map function appear in every programming language supporting “functional” concepts? And why does Swift have two map functions? We will answer these questions and show that map has many universal properties, and is in some sense unique.

Downloads

Get started with our free plan

Our free plan includes 1 subscriber-only episode of your choice, access to 64 free episodes with transcripts and code samples, and weekly updates from our newsletter.

View plans and pricing