Deriving generic class instances for datatypes

Jonas Rädle 📧 and Lars Hupel 🌐

November 6, 2018

This is a development version of this entry. It might change over time and is not stable. Please refer to release versions for citations.

Abstract

We provide a framework for automatically deriving instances for generic type classes. Our approach is inspired by Haskell's generic-deriving package and Scala's shapeless library. In addition to generating the code for type class functions, we also attempt to automatically prove type class laws for these instances. As of now, however, some manual proofs are still required for recursive datatypes.

Note: There are already articles in the AFP that provide automatic instantiation for a number of classes. Concretely, Deriving allows the automatic instantiation of comparators, linear orders, equality, and hashing. Show instantiates a Haskell-style show class.

Our approach works for arbitrary classes (with some Isabelle/HOL overhead for each class), but a smaller set of datatypes.

License

BSD License

Topics

Session Generic_Deriving