concept Gen in category functional programming
appears as: Gen, Gen

This is an excerpt from Manning's book Functional Programming with Kotlin.
We determined earlier that a
Gen<A>was something that knows how to generate values of typeA. How could it go about doing this? Well, it could randomly generate these values. Considering that we devoted all of chapter 6 to this topic, it would seem like we’re missing a trick if we don’t use what we learned in that chapter! Thinking back to our example, we provided an interface for a purely functional random number generator,RNG. We then showed how to make it convenient to combine computations that make use of it. If we recall the definition ofState, we can simply makeGena type that wraps aStatetransition over a random number generator.Listing 8.5. Define
Genby wrapping a state transition over a random number generatorinterface RNG { fun nextInt(): Pair<Int, RNG> } data class State<S, out A>(val run: (S) -> Pair<A, S>) data class Gen<A>(val sample: State<RNG, A>)