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|
Sun 23 Sep Times are displayed in time zone: Guadalajara, Mexico City, Monterrey change
|10:20 - 10:45|
Simon Peyton JonesMicrosoft, UKFile Attached
|10:45 - 11:10|
Matthew PickeringUniversity of BristolMedia Attached
|11:10 - 11:35|
Ryan ScottIndiana University at Bloomington, USAFile Attached
|11:35 - 11:43|
Chris SmithGoogle, USA
|11:43 - 11:51|
|11:51 - 12:00|
Samuel GélineauSimSpaceMedia Attached