🎉 Black Friday Sale! Save 30% when you subscribe today.
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.
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.
We’ve also seen that the zip
operation appears on a number of types, as explored in this series of episodes.
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.