coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: "Soegtrop, Michael" <michael.soegtrop AT intel.com>
- To: "coq-club AT inria.fr" <coq-club AT inria.fr>
- Subject: RE: [Coq-Club] Canonical Structures vs. Type Classes vs. Module Systems
- Date: Fri, 13 Apr 2018 16:57:18 +0000
- Accept-language: de-DE, en-US
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=michael.soegtrop AT intel.com; spf=Pass smtp.mailfrom=michael.soegtrop AT intel.com; spf=None smtp.helo=postmaster AT mga09.intel.com
- Ironport-phdr: 9a23:U/Xr4RWVi3w3lNRaj4dYBDmU81fV8LGtZVwlr6E/grcLSJyIuqrYbBOFt8tkgFKBZ4jH8fUM07OQ7/i7HzRYqb+681k6OKRWUBEEjchE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRoLerpBIHSk9631+ev8JHPfglEnjWwba98IRmssQndqtQdjJd/JKo21hbHuGZDdf5MxWNvK1KTnhL86dm18ZV+7SleuO8v+tBZX6nicKs2UbJXDDI9M2Ao/8LrrgXMTRGO5nQHTGoblAdDDhXf4xH7WpfxtTb6tvZ41SKHM8D6Uaw4VDK/5KptVRTmijoINyQh/W/XlMJ+kb5brhyiqRxxwYHUYZ2aO/VxcK7GYdMVXm5MUtpNWyBdAI6xaZYEAeobPeZfqonwv1UCowa5BQayC+Pv1iVIhnju3aEizu8vFgDG0xAgH90UrnvUqNv5P7oVXOCwzanH0TXDYOlI1jf58oTIaRchru+DXbJsa8rRzlEvGhjEjlWWtYzqITeV2v4RvGic6uptTOSigHMppQF2pzig3MYsio/Ri4Iay1DE6SV5wJsuKtGiSU57ZsaoEJpWtyGGKYR2RtkuTHx2tys817YIuoa7cTAXxJkpyBPTceGLfoaH7x75SeqcLzZ1iGh7dL+wnxq+7Emtx+PmWsS63ltGtDRJn9fIu3wXyhDe6dWLRuNg8kqg3TuDzR7f5+FLLEwui6bXMYMtz78/m5cVrE/NBDX5mF/sg6+Tbkgk+van6+DgYrj+o5+cOJV7hh36P6g0m8y/B/g4PRYKX2SB5eu807jj8VX4QLVMkPI2jrHUvI3UKMkUvKK1HgFY34k55xqiATqr0c4UkWcIIV5dfRKIlYnpO1XAIPDiCve/hkyhkDJqx//aPr3uGIvCLnzZnLf6erZy9UFcyBYpzdBY/5JZEbABIPTvWkDvsNzUFAM2Mwuxw+r/EtVyypseWX6TAq+eKK7drViI5vs2L+aQYI8VpS3yJuM+5//uiH85gUUScbOo3ZsRcnC4H+5pL1+XYXr20Z89FjJAtQ0nCefulVeqUDhJZn/0Ubh2rmUwD5vjBoPeTKishqaA1WG1BMsFSHpBDwXGKnDleJmeXO9IIAeTKc9onzhOHeykSoQh3Byq8hT9xrV7NO3M0iweqZ/nktNy4ruAxlkJ6TVoApHFgCm2RGZukzZQHm5k7OVEuUV4j2y7/+19iv1cG8ZU4qoQAAY8KZPYied9DoKrA16TTpKyUF+jB+6eL3QpVNtomo0PZVpwH5OpiRWRh3P3UY9QrKSCAdkPyoyZ33X1IJ8imXPJ3fFwyVggXsZLc2ahg/wn+g==
Dear Yao Li,
> Still I wonder what’s the reason that some libraries like mathcomp choose
> to use canonical structures? What are the advantages of them comparing with
> type classes?
since all the competent people seem to work on the next release let me
answer. Part of it might be historical (canonical structures existed before
type classes). One advantage of using canonical structure is that the
mathcomp library has in my opinion a better design and documentation than the
type class based Coq standard library. I don't want to blame or insult
anybody - it is just my impression that the Coq standard library was not
really designed but more or less happened over time while math components
look like someone really thought about it upfront. To be fair the standard
library is definitely improving, also due to increased and more consistent
use of type classes. For the mathcomp library a very well written open book
exists for documentation (https://math-comp.github.io/mcb/)
To make it short: if you want to use math components, you will use canonical
structures. If you base your work on something that is based on the type
classes in the standard library, you will use type classes. If you start on a
blank sheet without much need for a library (very unlikely) you have the pain
of choice, but I would upfront look at which library looks more useful for
whatever you are up to from a functionality point of view. If you really
don't need much of a library at all, I would suggest type classes - I also
find it a bit easier to debug and to work with, although this disadvantage is
I think well compensated by the better documentation of math components.
Regarding modules: I use modules for large things which get unwieldy with
type classes or canonical structures. I wouldn't write down the specification
or implementation of a larger software entity as a type class. If you say
have 100 requirements or implementation functions / theorems which you cannot
easily bundle or factorize into independent groups you would end up with a
type class constructor with 100 arguments and in some places you might end up
giving these 100 arguments in the right order. Modules are more suitable for
such things. Until you get into this situation you should be fine with type
classes or canonical structures. A small anecdote on this: when my wife got a
child we went to an information session in a hospital. One of the women asked
how she knows that she has contractions and should come to the hospital. The
doctor answered: "if you can still think about if you have contractions or
not, you don't have contractions". It is similar here.
I only use OCaml export (no Haskell) and there exporting modules works well
(the module systems of Coq and OCaml are very similar).
Hope it helps.
Best regards,
Michael
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
- [Coq-Club] Canonical Structures vs. Type Classes vs. Module Systems, Yao Li, 04/12/2018
- Re: [Coq-Club] Canonical Structures vs. Type Classes vs. Module Systems, John Wiegley, 04/12/2018
- Re: [Coq-Club] Canonical Structures vs. Type Classes vs. Module Systems, Yao Li, 04/13/2018
- Re: [Coq-Club] Canonical Structures vs. Type Classes vs. Module Systems, Andrew Appel, 04/13/2018
- Re: [Coq-Club] Canonical Structures vs. Type Classes vs. Module Systems, Matthieu Sozeau, 04/13/2018
- RE: [Coq-Club] Canonical Structures vs. Type Classes vs. Module Systems, Soegtrop, Michael, 04/13/2018
- Re: [Coq-Club] Canonical Structures vs. Type Classes vs. Module Systems, Yao Li, 04/13/2018
- Re: [Coq-Club] Canonical Structures vs. Type Classes vs. Module Systems, John Wiegley, 04/12/2018
Archive powered by MHonArc 2.6.18.