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.
In this section we utilize the “environment” method of dependency injection, which was first covered and motivated in the following episodes.
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!
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.