ComputingComputer ScienceCompilersData StructuresProgramming LanguagesAbstract Syntax TreesData TypesData-flow AnalysisFunctional ProgrammingGeneric ProgrammingType SystemsDatatypes TheoryGeneric FunctionsPolymorphic TypesStructural RepresentationType-level Programming
We introduce the sum-of-products (SOP) view for datatype-generic programming (in Haskell). While many of the libraries that are commonly in use today represent datatypes as arbitrary combinations of binary sums and products, SOP reflects the structure of datatypes more faithfully: each datatype is a single n-ary sum, where each component of the sum is a single n-ary product. This representation turns out to be expressible accurately in GHC with today's extensions. The resulting list-like structure of datatypes allows for the definition of powerful high-level traversal combinators, which in turn encourage the definition of generic functions in a compositional and concise style. A major plus of the SOP view is that it allows to separate function-specific metadata from the main structural representation and recombining this information later.
25
Koen Claessen, John Hughes · ACM SIGPLAN Notices · 2011 · 1K citations
Koen Claessen, John Hughes · 2000 · 714 citations
Template meta-programming for Haskell
Tim Sheard, Simon Peyton Jones · 2002 · 548 citations
Ralf Lämmel, Simon Peyton Jones · 2003 · 350 citations