## First-class type classes (2008)

Citations: | 38 - 1 self |

### BibTeX

@MISC{Sozeau08first-classtype,

author = {Matthieu Sozeau and Nicolas Oury},

title = {First-class type classes},

year = {2008}

}

### OpenURL

### Abstract

Abstract. Type Classes have met a large success in Haskell and Isabelle, as a solution for sharing notations by overloading and for specifying with abstract structures by quantification on contexts. However, both systems are limited by second-class implementations of these constructs, and these limitations are only overcomed by ad-hoc extensions to the respective systems. We propose an embedding of type classes into a dependent type theory that is first-class and supports some of the most popular extensions right away. The implementation is correspondingly cheap, general and integrates well inside the system, as we have experimented in Coq. We show how it can be used to help structured programming and proving by way of examples. 1

### Citations

353 | How to make ad-hoc Polymorphism less ad-hoc
- Wadler, Blott
- 1989
(Show Context)
Citation Context ...utomatically select an instance given a particular type. In the functional programming community, overloading has mainly been introduced by way of type classes, making ad-hoc polymorphism less ad hoc =-=[17]-=-. A type class is a set of functions specified for a parametric type but defined only for some types. For example, in the Haskell language, it is possible to define the class Eq of types that have an ... |

242 |
Principal type schemes for functional programs
- Damas, Milner
- 1982
(Show Context)
Citation Context ...ferent types of data. In our example, the method == can be used to compare any type of data, as long as this type has been declared an instance of the Eqclass. It also adds to the usual Damas–Milner =-=[4]-=- parametric polymorphism a form of ad-hoc polymorphism. E.g, one can constrain a polymorphic parameter to have an instance of a type class. =/= :: Eq a ⇒ a → a → Bool x =/= y = not (x == y) Morally, w... |

162 | Type classes with functional dependencies
- Jones
- 2000
(Show Context)
Citation Context ...endent records, implicit arguments, and proof automation. This simple setup, combined with the expressive power of dependent types subsumes some of the most popular extensions to Haskell type classes =-=[2,8]-=-. More precisely, in this paper, – we first recall some basic notions of type theory and some more specific notions we are relying on (§2) ; – then, we define type classes and instances before explain... |

74 | Type classes and overloading in higher-order logic
- Wenzel
- 1997
(Show Context)
Citation Context ...argument mechanism was done in the Scala object-oriented programming language [12] recently. Isabelle Haskell-style type classes are also an integral part of the Isabelle proof assistant [19]. Wenzel =-=[18]-=- has studied type classes in the Isabelle proofassistant, and recently F. Haftmann and him have given [6] a constructive explanation of the original axiomatic type classes in terms of locales [10]. T... |

68 | A compiled implementation of strong reduction
- Gregoire, Leroy
(Show Context)
Citation Context ...s having multiple superclasses or parameters and call a method it gets applied to a large number of arguments. The good thing is that both the interpreted evaluation functions and the virtual machine =-=[5]-=- of Coq are optimized to handle large applications. Also, we avoid trouble with proofs preventing reductions in terms that happen when using other styles of formalizations. 6.4 Searching The current t... |

42 | Typing algorithm in type theory with inheritance
- Saı̈bi
- 1997
(Show Context)
Citation Context ...rd projections, allowing to automatically use overloaded methods on the substructures when working with the composite structure. Remark This is very similar to the coercion mechanism available in Coq =-=[14]-=-, with which one can say that a structure is a subtype of another substructure. The source-level type-checking algorithm is extended to use this subtyping relation in addition to the usual conversion ... |

39 | Subset coercions in Coq
- Sozeau
- 2007
(Show Context)
Citation Context ...properly and permit giving only a subset of an instance’s fields explicitly, leaving the rest to be proved interactively. As shown in the examples, we also have a binding of type classes with Russell =-=[15]-=- that uses its enriched type system and allows to handle missing fields as obligations. 6.2 Naming We allow for a lot of names to be omitted by the user that we really need to have programmatically. T... |

37 | Locales - a sectioning concept for Isabelle
- Kammüller, Wenzel, et al.
- 1999
(Show Context)
Citation Context ...el [18] has studied type classes in the Isabelle proofassistant, and recently F. Haftmann and him have given [6] a constructive explanation of the original axiomatic type classes in terms of locales =-=[10]-=-. This explanation is not needed in our case because the evidence passing is done directly in the core language. We always have the kernel’s type-checker to tell us if the elaboration mechanism did so... |

20 | 2008. Generics of a higher kind
- Moors, Piessens, et al.
(Show Context)
Citation Context ...in the same functional language and is therefore much less contrived. Another embedding of type classes using an implicit argument mechanism was done in the Scala object-oriented programming language =-=[12]-=- recently. Isabelle Haskell-style type classes are also an integral part of the Isabelle proof assistant [19]. Wenzel [18] has studied type classes in the Isabelle proofassistant, and recently F. Haf... |

19 | Named instances for Haskell type classes
- Kahl, Scheffczyk
(Show Context)
Citation Context ...ly inferring the neutral element and the law of the monoid. If the context does not make clear which structure is used, it is always possible to be more precise (an extension known as named instances =-=[9]-=- in Haskell). Here the name M is overloaded to represent both the carrier and the (possibly numerous) structures built on it. These conventions are widely used, because they allow to write proofs, spe... |

16 | Axiomatic constructor classes in Isabelle/HOLCF
- Huffman, Matthews, et al.
- 2005
(Show Context)
Citation Context ... one has to work in an extension of HOL with Scott’s Logic of Computable Functions. It is then possible to construct axiomatic type classes for type constructors using a domain-theoretic construction =-=[7]-=-. Dependent Records Ample litterature exists on how to extend dependent type theories with records, e.g [3] gives a good starting point. We stress that our implementation did absolutely not change Coq... |

15 | Dependently typed records for representing mathematical structures
- Pollack
- 2000
(Show Context)
Citation Context ... one type to another in the definitions, obfuscating the term with coercions, and the user will also have to pass these equalities explicitly. The other possibility, known as Pebble-style structuring =-=[13]-=-, encourages the use of parameters instead. In this case, superstructures are explicitly specified as part of the structure type. Consider the following: Class [ C : Category obj hom, D : Category obj... |

14 | Constructive type classes in Isabelle
- Haftmann, Wenzel
- 2007
(Show Context)
Citation Context ...ll-style type classes are also an integral part of the Isabelle proof assistant [19]. Wenzel [18] has studied type classes in the Isabelle proofassistant, and recently F. Haftmann and him have given =-=[6]-=- a constructive explanation of the original axiomatic type classes in terms of locales [10]. This explanation is not needed in our case because the evidence passing is done directly in the core langua... |

4 |
Makoto Takeyama. A logical framework with dependently typed records
- Coquand, Pollack
- 2003
(Show Context)
Citation Context ...construct axiomatic type classes for type constructors using a domain-theoretic construction [7]. Dependent Records Ample litterature exists on how to extend dependent type theories with records, e.g =-=[3]-=- gives a good starting point. We stress that our implementation did absolutely not change Coq’s kernel and the associated type theory, and we would only benefit from more fully-featured records. 7.1 F... |

1 |
Programmation fonctionnelle certifie – L’extraction de programmes dans l’assistant Coq
- Letouzey
- 2004
(Show Context)
Citation Context ...hange Coq’s kernel and the associated type theory, and we would only benefit from more fully-featured records. 7.1 Future work Classes and Modules We could customize the existing extraction mechanism =-=[11]-=- from Coq to Haskell to handle type classes specially. However, this translation is partial as our type system is more powerful. It would be interesting to study this correspondence and also the conne... |