Module Generator.Debug

Helpers for debugging generators

val coverage : (module Base.Comparator.S with type comparator_witness = 'cmp and type t = 'k) -> 'k Base.Sequence.t -> ('k, Base.int, 'cmp) Base.Map.t

coverage (module Key) sample counts how many times each key appears in sample.

See Test.with_sample for a convenient way to generate sample.

val monitor : 'a t -> f:('a -> Base.unit) -> 'a t

monitor t ~f returns a generator which gives the same values as t and also calls f for each value. This can help diagnose behavior of generators "hidden" behind map, filter, etc. One might count the number of values a generator produces, or record the set of values that do not satisfy some filter.