liveBook · Manning

Algebraic law

An algebraic law is a general equation or behavioral property that an operation or implementation is expected to satisfy for applicable values.

How 2 Manning books explain it

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.

Read how Learn Haskell by Example explains algebraic law →

Related concepts

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.