/** * Maps the values produced by this generator with the specified partial * function, discarding any values the partial function is not defined at. * * @tsplus static effect/core/testing/Gen.Aspects collect * @tsplus pipeable effect/core/testing/Gen collect */ export function collect(pf: (a: A) => Maybe) { return (self: Gen): Gen => self.flatMap( (a) => pf(a).map(Gen.constant).getOrElse(Gen.empty) ) }