Algebraic law
An algebraic law is a general equation or behavioral property that an operation or implementation is expected to satisfy for applicable values.
Functional Programming in Scala, Second Edition
A law is a general equation or behavioral property that operations or their implementations are expected to satisfy.
- How it is used
- Constrain API operations and supply properties for reasoning, algebraic design, and property-based testing.
- How deep it goes
- Develops concrete mapping and flatMap equations, derives identity, and proves associativity for Option through case expansion.
- Examples
- Uses Par mapping, ExecutorService result comparison, Option cases, parser identities, and generated Order values.
- What you can do after
- Evaluate/understand whether alternative implementations preserve stated API behavior and derive reusable operations from lawful primitives.
Read how Functional Programming in Scala, Second Edition explains algebraic law →
Learn Haskell by Example
Property is the QuickCheck type representing a testable property, including properties augmented with conditions or classifications.
- How it is used
- Expresses implementation invariants as generated tests that search for counterexamples.
- How deep it goes
- Defines Bool and Property forms, demonstrates modifiers and shrinking, and defers custom Testable instances.
- Examples
- Uses sorted lists, rot13 symmetry, alphabet closure, and arithmetic properties in test suites.
- What you can do after
- Apply it via QuickCheck to run generated invariant checks and organize prop_-named tests into Stack suites.
Related concepts
- flatmapused by · FlatMap is an operation that applies a function producing nested collections or computational contexts to each element and combines the resulting contexts into one flattened result.
- monadpart of · A monad is a functional abstraction that encapsulates computational context and provides operations for composing computations while preserving that context.
- QuickCheckused by · QuickCheck is a property-based testing library that generates test inputs from specifications, checks their properties, and may minimize failing counterexamples.
- property-based testingused by · 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.
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.

