liveBook · Manning

Algebraic data type

Also called ADTs

An algebraic data type is a composite type whose values are formed from product structures, finite alternatives, or both through type constructors.

How 6 Manning books explain it

Functional Design and Architecture: Examples in Haskell

An algebraic data type is a composite type formed from alternatives, products, or both, with its structure described by type constructors.

How it is used
Models business domains, complex data structures, and operations in embedded domain-specific languages.
How deep it goes
Develops constructor-based models, interpreter separation, encapsulation, and parameterized ADTs with continuations or type-level field selection.
Examples
Uses smart-home sensor operations and measurements, a sandwich-construction language, and domain and database variants of a meteor model.
What you can do after
Build ADT-based domain models and interpretable DSL descriptions, and encapsulate representations with modules and smart constructors.

Read how Functional Design and Architecture: Examples in Haskell explains algebraic data type →

The Joy of JavaScript

A composite type formed by combining simpler types with sum and product structure to represent a finite set of possibilities.

How it is used
Uses composable objects to handle validation, errors, and mutually exclusive outcomes without scattering checks through function pipelines.
How deep it goes
Defines immutable composite types, distinguishes records from choices, and works through validation chains and a Promise analogy.
Examples
Uses an immutable Pair, success-or-failure validation, a blockchain-checking chain, and Promise states.
What you can do after
Build it from scratch as a Validation type and compose checks with flatMap instead of repeated branching.

Read how The Joy of JavaScript explains algebraic data type →

Data-Oriented Programming in Java

An algebraic data type is a composite type whose values are formed by combining product and sum alternatives of other types.

How it is used
Models domain facts and mutually exclusive states so requirements become precise Java data types.
How deep it goes
Explains product and sum operators, symbolic laws, optionality, and a preview of algebraic refactoring; defers detailed practice.
Examples
Uses checklists, Coffee/Tea/Milk drinks, Optional, and late-fee billing decisions to show type combinations and alternatives.
What you can do after
Evaluate/understand domain models as explicit AND/OR type shapes and sketch refactorings before committing to implementations.

Read how Data-Oriented Programming in Java explains algebraic data type →

Functional Programming in Scala, Second Edition

An algebraic data type is a data type defined as a sum of one or more data constructors, where each constructor is a product of its arguments.

How it is used
Models immutable functional data structures and explicit success-or-failure values for pure, pattern-matched computation.
How deep it goes
Defines sums and products, demonstrates Scala encodings, and works through recursive tree and list operations without formal algebraic derivations.
Examples
Uses tuples, binary trees, singly linked lists, and error types including Option, Either, Try, and Validated.
What you can do after
Build immutable lists and trees, operate on their constructors with pattern matching, and represent errors as composable values.

Read how Functional Programming in Scala, Second Edition explains algebraic data type →

Learn Haskell by Example

An algebraic data type is a user-defined type formed from one or more named constructors, potentially carrying fields.

How it is used
Encodes command-line options so parsing and later control-flow decisions operate on named values rather than raw strings.
How deep it goes
Defines constructors and applies them in parsing, comparison, and function selection, while deferring a detailed treatment of deriving.
Examples
Uses line-numbering options for reversing numbering, skipping empty lines, and left-aligning output.
What you can do after
Build command-line option representations and parsers that select different line-numbering behaviors.

Read how Learn Haskell by Example explains algebraic data type →

Write Powerful Rust Macros

An algebraic data type is a composite type formed from product and sum type constructors to represent a defined set of values.

How it is used
Frames algebraic data types as a practical foundation for representing success and failure without exceptions.
How deep it goes
Defines product and sum types, then demonstrates enum matching and value mapping without developing their full implementation details.
Examples
Uses a u8-and-boolean struct, an Either success/failure enum, matching, and a map operation.
What you can do after
Apply enums and pattern matching to represent and handle explicit success-or-failure outcomes.

Read how Write Powerful Rust Macros explains algebraic data type →

Also covered in

What to know first

Related concepts

Questions about algebraic data type

What is algebraic data type?

An algebraic data type is a composite type whose values are formed from product structures, finite alternatives, or both through type constructors.

Which Manning books explain algebraic data type?

Functional Design and Architecture: Examples in Haskell, The Joy of JavaScript, Data-Oriented Programming in Java, Functional Programming in Scala, Second Edition, Learn Haskell by Example and Write Powerful Rust Macros.

What should I know before learning algebraic data type?

Manning books that teach algebraic data type usually introduce atomic type, functional programming, pattern matching and list first.

What kinds of algebraic data type are there?

Kinds of algebraic data type include Either, option, tuple and union type.

What is algebraic data type also called?

Algebraic data type is also called ADTs.

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.