# th-abstraction

> One interface to Template Haskell's datatype information across GHC versions

Source: https://talira.ai/catalog/th-abstraction-ebd79nxp
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [developer tools / code generation](https://talira.ai/categories/developer-tools/code-generation), [languages / haskell](https://talira.ai/categories/languages/haskell)
- Licence: ISC[^1]
- Pricing: Free and open source[^1]
- Pricing notes: Free and open source (ISC).
- Free tier: yes[^1]
- Backed by: [Eric Mertens](https://talira.ai/orgs/glguy.md)

th-abstraction is a Haskell library for authors of Template Haskell code. It gives a single, consistent view of the reified information about datatypes, newtypes and data family instances, hiding the differences between normal and GADT syntax and between Template Haskell versions, so a deriving library or code generator can support many GHC releases with one code path. Its modules are Language.Haskell.TH.Datatype and Language.Haskell.TH.Datatype.TyVarBndr. Install it from Hackage as th-abstraction.

## Links

- GitHub: https://github.com/glguy/th-abstraction
- Docs: https://hackage.haskell.org/package/th-abstraction

## Problems it solves

- my Template Haskell deriving code breaks on every new GHC release
- write Template Haskell that handles GADTs and ordinary data types the same way
- inspect a data type's constructors and fields from Template Haskell across GHC versions

## Features

- normalized reified datatype, newtype and data family instance information
- hides normal versus GADT syntax differences
- supports many Template Haskell versions
- tested on GHC 8.0 to 9.14

## Trust

Overall: 0.23 out of 1.
Signals: maintenance 0.27, adoption 0.26, momentum 0.02, community 0.36, backing 0.30, extensibility 0.00.

- 20 GitHub stars
- 7 contributors
- backed by Eric Mertens

Warnings:

- last commit 10 months ago

## Alternatives

- [th-lift](https://talira.ai/catalog/th-lift-24br7pf5.md): Derive Template Haskell's Lift class for datatypes
- [generic-deriving](https://talira.ai/catalog/generic-deriving-x1bhjkjw.md): Generic programming library for generalised deriving in Haskell

## Sources

[^1]: https://github.com/glguy/th-abstraction/blob/master/LICENSE (checked 28 Nov 2026)
