geny
package geny
- Alphabetic
- Public
- All
Type Members
-
trait
Generator
[+A] extends AnyRef
Provides the
geny.Gendata type, A Generator of elements of type A.Provides the
geny.Gendata type, A Generator of elements of type A.Generator is basically the inverse of a
scala.Iterator: instead of the core functionality being the pull-basedhasNextandnext: Tmethods, the core is based around the push-basedgeneratemethod.generateis basically an extra-customizable version offoreach, which allows the person calling it to provide basic control-flow instructions to the upstream Gens.Unlike a
scala.Iterator, subclasses of Generator can guarantee any clean up logic is performed by placing it after thegeneratecall is made.Transformations on a Generator are lazy: calling methods like
filterormapdo not evaluate the entire Gen, but instead construct a new Gen that delegates to the original. The only methods that evaluate the Generator are the "Action" methods likegenerate/foreach/find, or the "Conversion" methods liketoArrayor similar.generatetakes a function returningGen.Actionrather thatUnit. This allows a downstream Gen to provide basic control commands to the upstream Gens: i.e. Generator.End to cease enumeration of the upstream Gen. This allows it to avoid traversing and processing elements that the downstream Gen doesn't want/need to see anyway.