Hasty Briefsbeta

Bilingual

Type-checked non-empty strings

3 days ago
  • #Compile-Time Validation
  • #Type-Level Programming
  • #Haskell
  • Introduced a type-checked non-empty string constructor in Haskell using RequiredTypeArguments for compile-time validation.
  • Replaced thousands of TemplateHaskell splices with the new approach, achieving a ~10% build-time improvement in a data-heavy package.
  • Implemented a type-level predicate IsNonEmptySymbol with custom type errors for empty strings, using type families and typeclasses.
  • Extended the technique to validate other types, like positive Natural numbers, and demonstrated type-level parsing for DynamoDB table names.
  • Highlighted limitations of type-level programming in Haskell, such as GHC's reduction limits and awkward expression of non-trivial algorithms.