Write a Blog >>
ICFP 2018
Sun 23 - Sat 29 September 2018 St. Louis, Missouri, United States
Sun 23 Sep 2018 11:10 - 11:35 at Illinois Central - GHC Chair(s): Ben Gamari

GHC.Generics has seen enormous success as a tool for writing datatype-generic programs in Haskell. But its scope is currently limited, as the API that GHC.Generics exposes is only suitable for working plain old abstract datatypes. That is, one cannot write sensible Generic instances for GADTs.

In this talk, we propose an extension to GHC.Generics which would bridge this gap. Our technique relies on three observations:

  • One can express any GADT in an equivalent form where all existential quantification is made explicit.
  • Using various GHC language extensions, one can construct generic representation types that model existential quantification at the type level.
  • Using the QuantifiedConstraints language extension, one can reason about existentially quantified types in class instances without needing to know what those types are ahead of time.

We will demonstrate this technique to generically derive instances for progressively more complex GADTs, and briefly discuss how our work could be simplified by future GHC extensions, such as dependent types.

Slides: Generalized Abstract GHC.Generics (gagg-no-nums.pdf)209KiB