liveBook · Manning

Type family

As explained in 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.

A type family is a type-level function: it accepts type-level marks and computes the result type needed by a polymorphic data structure. In the HKD pattern, this lets one meteor record shape represent domain, SQLite, and Postgres variants. section 12.1.3

The design separates shared structure from representation-specific field types:

  • Let TypeSelector choose each concrete field type at compile time, preserving common construction, access, and pattern matching. section 12.1.3

Meteor representations

The same Meteor constructor can produce a domain Meteor with Int and Float fields or a SQLiteMeteor with INTEGER and FLOAT fields; getSize consequently returns different types.

How Functional Design and Architecture: Examples in Haskell covers it

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 it assumes
Assumes familiarity with polymorphic records and type-level marks while introducing the selection mechanism through a concrete data model.
What you can do after
Apply it via a closed TypeSelector family to define shared records whose field types vary by representation.
How it connects
Connects type families with HKD patterns, polymorphic algebraic data types, type-level programming, and compile-time type selection.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Design and Architecture: Examples in Haskell. The section links point to the parts of the book it draws on.