$ show goldfirere/singletons
This repository provides a Haskell library for generating singleton types and promoted versions of data types and functions using Template Haskell. It enables dependently typed programming in Haskell by lifting term-level code to the type level and providing singleton types that mirror term-level values. The library is split into three packages: `singletons` (core functionality with broad GHC compatibility), `singletons-base` (promoted/singled versions of the base library), and `singletons-th` (Template Haskell machinery for code generation). Key features include automatic generation of defunctionalization symbols for higher-order type-level programming, derivation of type class instances for singleton types, and support for kind polymorphism.
The LLM identified 2 files worth highlighting for reuse:
Provides utilities for name handling during Template Haskell code generation, including freshening names and handling scoped type variables. This module is isolated, depends only on base and TH libraries, and solves the generic problem of avoiding name capture in code generation, making it reusable in any TH-based project.
Defines the PrM monad that manages state during promotion (scoped variables, local bindings, and fresh name supply). This encapsulates complex state needed for multi-pass code generation in a reusable pattern, demonstrating non-obvious skill in structuring TH-based transformations while maintaining low coupling to other modules.