This post is part of a series of posts on implementing a minimal version of QuickCheck from scratch. The source code is available on GitHub.
In the previous post I’ve generated random characters. In this post, I’ll be doing the same for booleans.
Two generators are required for this, which have been ported already on previous posts:
- a generator that lifts a value to the elevated world of generators; that’s the one ported as
- a generator that randomly uses one of the above generators, that’s
Given the above, a boolean generator can be written as:
Finally, here are some sample booleans: