*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.*

We already have a function that runs a generator `Gen<'a>`

and returns random test data of type `'a`

.

Now, in order to be able to generate random bytes, we need a couple of generators:

- a generator that picks numbers from a given range (in this case [0..255])
- a generator that applies a function (in this case
`Operators.byte<^T>`

) to an existing generator

Porting Gen’s `choose`

Porting Gen’s `map`

, `bind`

, and `return`

^{1} since `choose`

depends on them

All the pieces are now in place, and so a byte generator can be written as:

Finally, here are some sample bytes: