talira

syb (Scrap Your Boilerplate)

Scrap Your Boilerplate generic programming for Haskell

open sourceBSD-3-Clause AND HaskellReportfree

syb is the Haskell library for Scrap Your Boilerplate (SYB) generic programming, originally developed by Ralf Lämmel and Simon Peyton Jones. It defines the Data class, whose instances GHC can derive for your own types, with instances for primitive types, and a set of generic functions built on type-safe cast and constructor applications: traversal schemes such as everywhere and everything, and generic read, show and equality (gread, gshow, geq). It lets one function walk or rewrite every value of a type inside a large data structure without writing a case for each constructor.

Problems it solves

  • update every occurrence of a type deep inside a big Haskell data structure without writing a case for each constructor
  • collect all values of some type from a nested Haskell AST
  • write a generic show or equality that works for any Haskell data type

Features

  • Traversal schemes such as everywhere and everything over any Data type
  • Generic read, show and equality (gread, gshow, geq)
  • GHC derives the Data and Typeable instances for your own types
  • Type-safe cast and constructor-application primitives for writing your own generic functions