Composable Parsing: Map, Zip, Flat‑Map

Section • 3 episodes • 1 hr 4 min

We’ll define the functional trio of operations on the Parser type: map, zip and flatMap. They introduce a familiar means of transforming and combining simple parsers into more and more complex parsers that can extract out first class data from nebulous blobs of data.

Related content

The Parser type isn’t the only type that supports map, zip and flatMap operations. There are many types that can be transformed in similar ways, and even the Swift standard library and Apple frameworks ship with many examples. This collection of episodes explores this topic deeply, and hopes to empower you to define these operations on your own types as well.

Map, Zip, Flat‑Map
4 hr 27 min

Where to go from here

Now that we’ve seen that parsers have map, zip, and flatMap operations, it’s time to take things to the next level and explore a whole bunch of what are commonly called “parser combinators”: or “higher-order” functions that enhance and combine parsers in more and more interesting, complex ways.