- Author
- Mike Ledger, Bellroy
- Published
- 23 June 2026
- Kind
- Company engineering blog post, with code and one build-time figure
- Original
- exploring-better-ways.bellroy.com/haskell-koan-type-checked-non-empty-strings.html
- Subject
- Programming languages and types
What it is
Mike Ledger writes on the Bellroy engineering blog. The post presents a small, uncommon technique the team uses and enjoys. It explains the code step by step and shows where it stops working.
What it says
- Replacing thousands of Template Haskell calls cut one package's build time about 10%.
- An overlapping instance for the empty string is chosen and raises the custom error.
- The trick passes a type-level string to a function using RequiredTypeArguments, added in GHC 9.10.
- The check becomes a typeclass because a type family is no ordinary constraint.
- The same approach can check a Natural is positive, or any type-level predicate.
- Type-level parsing hits GHC's default reduction limit of 20, capping input near 20 characters.
- A longer example validates DynamoDB table names using a type family and an inner typeclass.
What evidence it gives
The post gives code at each step. It reports one result: about 10% less compile time. No benchmark method is shown.
Interests and limits
Bellroy is the author's employer, and the post describes its own practice. The build-time figure comes from one package and is stated loosely. The technique needs a recent compiler and UndecidableInstances.