liveBook · Manning

Type family

A type family is a collection of types whose members or resulting type are determined by one or more indices or input types.

How 2 Manning books explain it

Type-Driven Development with Idris

A type family is a collection of types whose specific type is determined by one or more indices.

How it is used
Uses indices in dependent data types to distinguish related types and express constraints on function inputs and results.
How deep it goes
Works through indexed declarations and vector functions, including case splitting, but does not develop the underlying type theory.
Examples
Uses vehicles indexed by power source and vectors indexed by length, with append and zip as operations.
What you can do after
Build indexed data types and write functions whose types constrain valid inputs and results.

Read how Type-Driven Development with Idris explains type family →

Functional Design and Architecture: Examples in Haskell

A type family is a type-level function that computes a result type from one or more input types.

How it is used
Uses type-level selection to share one record structure across domain and database representations.
How deep it goes
Explains parameters, equations, aliases, and closed-family extensibility, but stops short of broader HKD techniques.
Examples
Uses meteor records, domain types, SQLite wrappers, Postgres wrappers, and a TypeSelector mapping table.
What you can do after
Apply it via a closed TypeSelector family to define shared records whose field types vary by representation.

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

What to know first

Related concepts

Questions about type family

What is type family?

A type family is a collection of types whose members or resulting type are determined by one or more indices or input types.

Which Manning books explain type family?

Type-Driven Development with Idris and Functional Design and Architecture: Examples in Haskell.

What should I know before learning type family?

Manning books that teach type family usually introduce data type first.

What kinds of type family are there?

Kinds of type family include closed type family.

What is type family a kind of?

Type family is a kind of type-level design. A software design technique that encodes behavioral constraints and correctness conditions in types so the compiler can check 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.