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.

The Problem
Introduction
00:05
Parser recap
00:59
The need for parser builders
15:44
Next time: result builders
27:48

Unlock This Episode

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

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.

This episode is for subscribers only.

Subscribe to Point-Free

Access this episode, plus all past and future episodes when you become a subscriber.

See plans and pricing

Already a subscriber? Log in

References

Collection: Parsing

Brandon 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 Parsing

Brandon 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 Processing

Alex 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.

The Many Faces of Map

Brandon Williams & Stephen Celis • Monday Apr 23, 2018

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