Gen

final case class Gen[-R, +A](sample: ZStream[R, Nothing, Sample[R, A]])

A Gen[R, A] represents a generator of values of type A, which requires an environment R. Generators may be random or deterministic.

Companion:
object
trait Product
trait Equals
class Object
trait Matchable
class Any
Gen[R, A]

Value members

Concrete methods

def <&>[R1 <: R, B](that: Gen[R1, B]): Gen[R1, (A, B)]

A symbolic alias for zip.

A symbolic alias for zip.

def <*>[R1 <: R, B](that: Gen[R1, B]): Gen[R1, (A, B)]

A symbolic alias for cross.

A symbolic alias for cross.

def collect[B](pf: PartialFunction[A, B]): Gen[R, B]

Maps the values produced by this generator with the specified partial function, discarding any values the partial function is not defined at.

Maps the values produced by this generator with the specified partial function, discarding any values the partial function is not defined at.

def cross[R1 <: R, B](that: Gen[R1, B]): Gen[R1, (A, B)]

Composes this generator with the specified generator to create a cartesian product of elements.

Composes this generator with the specified generator to create a cartesian product of elements.

def crossWith[R1 <: R, B, C](that: Gen[R1, B])(f: (A, B) => C): Gen[R1, C]

Composes this generator with the specified generator to create a cartesian product of elements with the specified function.

Composes this generator with the specified generator to create a cartesian product of elements with the specified function.

def filter(f: A => Boolean): Gen[R, A]

Filters the values produced by this generator, discarding any values that do not meet the specified predicate. Using filter can reduce test performance, especially if many values must be discarded. It is recommended to use combinators such as map and flatMap to create generators of the desired values instead.

Filters the values produced by this generator, discarding any values that do not meet the specified predicate. Using filter can reduce test performance, especially if many values must be discarded. It is recommended to use combinators such as map and flatMap to create generators of the desired values instead.

val evens: Gen[Random, Int] = Gen.anyInt.map(_ * 2)
def filterNot(f: A => Boolean): Gen[R, A]

Filters the values produced by this generator, discarding any values that meet the specified predicate.

Filters the values produced by this generator, discarding any values that meet the specified predicate.

def flatMap[R1 <: R, B](f: A => Gen[R1, B]): Gen[R1, B]
def flatten[R1 <: R, B](implicit ev: A <:< Gen[R1, B]): Gen[R1, B]
def map[B](f: A => B): Gen[R, B]
def mapM[R1 <: R, B](f: A => ZIO[R1, Nothing, B]): Gen[R1, B]

Maps an effectual function over a generator.

Maps an effectual function over a generator.

def noShrink: Gen[R, A]

Discards the shrinker for this generator.

Discards the shrinker for this generator.

def reshrink[R1 <: R, B](f: A => Sample[R1, B]): Gen[R1, B]

Discards the shrinker for this generator and applies a new shrinker by mapping each value to a sample using the specified function. This is useful when the process to shrink a value is simpler than the process used to generate it.

Discards the shrinker for this generator and applies a new shrinker by mapping each value to a sample using the specified function. This is useful when the process to shrink a value is simpler than the process used to generate it.

def runCollect: ZIO[R, Nothing, List[A]]

Runs the generator and collects all of its values in a list.

Runs the generator and collects all of its values in a list.

def runCollectN(n: Int): ZIO[R, Nothing, List[A]]

Repeatedly runs the generator and collects the specified number of values in a list.

Repeatedly runs the generator and collects the specified number of values in a list.

def runHead: ZIO[R, Nothing, Option[A]]

Runs the generator returning the first value of the generator.

Runs the generator returning the first value of the generator.

def withFilter(f: A => Boolean): Gen[R, A]
def zip[R1 <: R, B](that: Gen[R1, B]): Gen[R1, (A, B)]

Zips two generators together pairwise. The new generator will generate elements as long as either generator is generating elements, running the other generator multiple times if necessary.

Zips two generators together pairwise. The new generator will generate elements as long as either generator is generating elements, running the other generator multiple times if necessary.

def zipWith[R1 <: R, B, C](that: Gen[R1, B])(f: (A, B) => C): Gen[R1, C]

Zips two generators together pairwise with the specified function. The new generator will generate elements as long as either generator is generating elements, running the other generator multiple times if necessary.

Zips two generators together pairwise with the specified function. The new generator will generate elements as long as either generator is generating elements, running the other generator multiple times if necessary.

Inherited methods

Inherited from:
Product