liveBook · Manning

Generalized algebraic data type

Also called GADT

A generalized algebraic data type is an algebraic data type whose constructors can impose more specific types on its type parameters.

How 2 Manning books explain it

Functional Design and Architecture: Examples in Haskell

A generalized algebraic data type is an algebraic data type whose constructors can provide more specific type information than the surrounding type declaration.

How it is used
Uses GADTs to model typed operations in domain-specific languages and dependency-inverted service interfaces.
How deep it goes
Explains constructor-specific results, localized types, continuations, and interpreters through Haskell declarations and a comparison with free monads.
Examples
Shows device status and sensor operations, an embedded hardware script with a continuation, and a meteor-reporting service.
What you can do after
Apply GADTs to define typed API operations and interpret them, while evaluating when a free-monad interface better supports sequential scenarios.

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

Learn Haskell by Example

A generalized algebraic data type allows data constructors to specify more precise type information than ordinary algebraic data types.

How it is used
Uses constructor-specific types to recover precise information while processing polymorphic parsing and image data.
How deep it goes
Explains syntax, constructor-driven refinement, pattern matching, and existential composition, stopping short of broader implementation internals.
Examples
Demonstrates GiveMe values, typed PNM images, and conversion from 8-bit to 16-bit pixels.
What you can do after
Build it from scratch using GADTs to write type-safe polymorphic functions and dynamically store typed image values.

Read how Learn Haskell by Example explains generalized algebraic data type →

Also covered in

Related concepts

Questions about generalized algebraic data type

What is generalized algebraic data type?

A generalized algebraic data type is an algebraic data type whose constructors can impose more specific types on its type parameters.

Which Manning books explain generalized algebraic data type?

Functional Design and Architecture: Examples in Haskell and Learn Haskell by Example.

What is the difference between generalized algebraic data type and free monad?

A generalized algebraic data type is an algebraic data type whose constructors can impose more specific types on its type parameters. A free monad represents computations as composable syntax over an operation set, with interpretation and execution supplied separately.

What is generalized algebraic data type a kind of?

Generalized algebraic data type is a kind of 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.

What is generalized algebraic data type also called?

Generalized algebraic data type is also called GADT.

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.