Generator Operations
#
NextIf you want to use an Arb to just return a value (even outside of a property test), then you can call next on it.
#
FilterIf you have an arb and you want to create a new arb that provides a subset of values, you can call filter on the source arb. For example, one way of generating even numbers is to take the integer arb, and filter out odd values. Viz:
#
MapIf you have an arb and you want to transform the value generated, you can use map.
#
FlatMapIf you have an arb whose emission or edgecases depends on the emission of the previous arbitraries, you can use flatMap.
#
MergingTwo generators can be merged together, so that elements 0, 2, 4, ... are taken from the first generator, and elements 1, 3, 5, ... are taken from the second generator.
So with the following example:
Would ouput ababababab
#
BindBind is useful if you want to apply multiple arbitraries. We can take a look at how we might construct values for a data class using bind.