Instance chains
Authors:
Open Access
- 27 September 2010
- journal article
- Published by Association for Computing Machinery (ACM) in ACM SIGPLAN Notices
- Vol. 45 (9) , 375-386
Abstract
Type classes have found a wide variety of uses in Haskell programs, from simple overloading of operators (such as equality or ordering) to complex invariants used to implement type-safe heterogeneous lists or limited subtyping. Unfortunately, many of the richer uses of type classes require extensions to the class system that have been incompletely described in the research literature and are not universally accepted within the Haskell community. This paper describes a new type class system, implemented in a prototype tool called ilab , that simplifies and enhances Haskell-style type-class programming. In ilab , we replace overlapping instances with a new feature, instance chains , allowing explicit alternation and failure in instance declarations. We describe a technique for ascribing semantics to type class systems, relating classes, instances, and class constraints (such as kind signatures or functional dependencies) directly to a set-theoretic model of relations on types. Finally, we give a semantics for ilab and describe its implementation.Keywords
This publication has 9 references indexed in Scilit:
- Experience report2010
- Language and program design for functional dependencies2008
- Type checking with open type functions2008
- Data types à la carteJournal of Functional Programming, 2008
- Understanding functional dependencies via constraint handling rulesJournal of Functional Programming, 2007
- Strongly typed memory areas programming systems-level data structures in a functional language2006
- Type Class DirectivesLecture Notes in Computer Science, 2005
- Strongly typed heterogeneous collections2004
- How to make ad-hoc polymorphism less ad hoc1989