Forall
forall is a property-testing combinator that constructs a property by applying a predicate to values generated from specified generators.
Functional Programming in Scala, Second Edition
Prop.forAll is a ScalaCheck API function that constructs a property by applying a predicate to values generated by a Gen.
- How it is used
- States generated-input laws as composable properties for property-based testing.
- How deep it goes
- Derives the polymorphic signature and implements execution with random inputs, result reporting, exceptions, and exhaustive-domain refinement.
- Examples
- Uses list reversal laws, Boolean properties, sorted lists, maximums, and a deliberately falsified reverse-equals-self claim.
- What you can do after
- Build it from scratch as a generator-driven test loop that returns passing or falsified results with diagnostics.
Read how Functional Programming in Scala, Second Edition explains forall →
Learn Haskell by Example
forAll is a QuickCheck combinator that attaches an explicitly supplied generator to a property test.
- How it is used
- Attaches a custom `Gen` generator to a QuickCheck property when test inputs require explicit control.
- How deep it goes
- Shows a complete generator and property pairing, then defers reusable generation to `Arbitrary` instances.
- Examples
- Uses a nonempty alphabet, bounded rotation count, and selected alphabet character to test `alphabetRot` closedness.
- What you can do after
- Apply it via QuickCheck to test a predicate against deliberately generated cases.
Related concepts
- property-based testinguses · Property-based testing is a software-testing technique that generates varied inputs and checks whether specified general properties of the software’s behavior hold across them.
- generatoruses · A generator is a computational component or construct that produces data or values from inputs, representations, context, or specified constraints.
- predicateuses · A predicate is a condition, expression, or function evaluated against an input or context to determine whether a specified criterion holds.
- existential typeused by · An existential type hides a concrete type while exposing values and operations guaranteed by constraints on that type.
- exceptionuses · An exception is a runtime signal or object representing an abnormal condition that interrupts ordinary program flow and may be handled or propagated.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

