Predictable Randomness

Section • 2 episodes • 1 hr 9 min

It’s time to make composable randomness predictable. We will make the Gen type compatible with Swift’s new APIs, explore various ways of controlling those APIs, both locally and globally, and define the flatMap operation.

Related content

In this section we utilize the “environment” method of dependency injection, which was first covered and motivated in the following episodes.

Dependency Injection Made Easy
35 min
Dependency Injection Made Comfortable
28 min

The flatMap operation we defined on Gen is the third of our functional toolkit trio, which we covered over the course of the following five episodes!

Flat‑Map
2 hr 26 min

Where to go from here

Now that we’ve covered the basics of randomness let’s have some fun! We’ll use the tools we’ve built in the previous sections to explore how we can create some generative art, and even write tests to that it works the way we expect.