Skip to content

Class instances for Coq inductive types with little boilerplate

License

Notifications You must be signed in to change notification settings

floriangru/deriving

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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_coqIndMixin := Eval simpl in [indMixin for foo_rect].
Canonical foo_coqIndType := CoqIndType _ foo foo_coqIndMixin.

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.

Requirements

Build instructions

To compile, do

make

To install, do

make install

TODO

  • Documentation

  • Clean up code

  • Support mutually inductive types

About

Class instances for Coq inductive types with little boilerplate

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Coq 98.6%
  • Makefile 1.4%