Composable Randomness

Section • 3 episodes • 1 hr 28 min

Let’s look at randomness under the lens of functional programming. We’ll describe randomness using a simple function signature, explore some of its transformable, composable properties, and compare these APIs to the ones that ship with the Swift standard library.

Related content

The map operation we define on the Gen type shows up on many, many types. In this episode we explore map in far more depth and see that there’s something universal about its definition.

The Many Faces of Map
31 min

We’ve also seen that the zip operation appears on a number of types, as explored in this series of episodes.

Zip
1 hr 29 min

Where to go from here

Exploring composition in terms of randomness has given us a truly powerful set of APIs for generating more and more complex forms of randomness, but we have no way of testing any of them. In the next section we will show how it’s possible to control randomness in predictable, testable ways.