Skip to content
Class instances for Coq inductive types with little boilerplate
Coq Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Deriving ─ Generic instances for Coq inductive types

The Deriving library builds instances of basic MathComp classes for inductive data types with little boilerplate, akin to Haskell's deriving functionality. To define an eqType instance for a type foo, just write:

From mathcomp Require Import ssreflect eqtype.
From deriving Require Import deriving.

Inductive foo := Foo of nat.

Definition foo_indMixin := Eval simpl in [indMixin for foo_rect].
Canonical foo_indType := IndType _ foo foo_indMixin.

Definition foo_eqMixin := Eval simpl in [derive eqMixin for foo].
Canonical foo_eqType := EqType foo foo_eqMixin.

Usage and limitations

Besides eqType, there are predefined generic instances for choiceType, countType and finType. Check out the examples in theories/examples.v. You can also write generic instances for your own classes (though this currently requires some non-trivial dependently typed hacking). Currently, the library does not support nested inductive types, mutual inductive types or indexed types.


Build instructions

To compile, do


To install, do

make install


  • Documentation

  • Clean up code

  • Support mutually inductive types

You can’t perform that action at this time.