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.
Supplemental Material
- }}I. S. Diatchki and M. P. Jones. Strongly typed memory areas: programming systems-level data structures in a functional language. In Haskell '06, pages 72--83, Portland, Oregon, USA, 2006. ACM. Google Scholar
Digital Library
- }}T. Hallgren. Fun with functional dependencies, or (draft) types as values in static computations in Haskell. In Proc. of the Joint CS/CE Winter Meeting, 2001.Google Scholar
- }}B. Heeren and J. Hage. Type class directives. In PADL '05, pages 253--267. Springer-Verlag, 2005. Google Scholar
Digital Library
- }}M. P. Jones. A theory of qualified types. In B. K. Bruckner, editor, ESOP '92, volume 582. Springer-Verlag, London, UK, 1992. Google Scholar
Digital Library
- }}M. P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, 1994. Google Scholar
Digital Library
- }}M. P. Jones. Type classes with functional dependencies. In ESOP 2000, pages 230--244, London, UK, 2000. Springer-Verlag. Google Scholar
Digital Library
- }}M. P. Jones and I. S. Diatchki. Language and program design for functional dependencies. In Haskell Symp., pages 87--98, Victoria, BC, Canada, 2008. ACM. Google Scholar
Digital Library
- }}O. Kiselyov and R. Lämmel. Haskell's overlooked object system. Draft; Submitted for publication; online since 10 Sept. 2005.Google Scholar
- }}O. Kiselyov, R. Lämmel, and K. Schupke. Strongly typed heterogeneous collections. In Haskell '04, pages 96--107, Snowbird, Utah, USA, 2004. ACM Press. Google Scholar
Digital Library
- }}D. Maier. The Theory of Relational Databases. Computer Science Press, 1983. Google Scholar
Digital Library
- }}J. G. Morris. Experience report: Using Hackage to inform language design. In Haskell '10, Baltimore, Maryland, USA, 2010. ACM. Google Scholar
Digital Library
- }}M. Neubauer, P. Thiemann, M. Gasbichler, and M. Sperber. A functional notation for functional dependencies. In Haskell '01, Firenze, Italy, September 2001.Google Scholar
- }}S. Peyton Jones, M. P. Jones, and E. Meijer. Type classes: an exploration of the design space. In Haskell '97, Amsterdam, The Netherlands, June 1997.Google Scholar
- }}T. Schrijvers, S. Peyton Jones, M. Chakravarty, and M. Sulzmann. Type checking with open type functions. In IFCP '08, pages 51--62, Victoria, BC, Canada, 2008. ACM. Google Scholar
Digital Library
- }}J. Shapiro, S. Sridhar, and S. Doerrie. BitC (0.11 transitional) language specification. http://www.bitc-lang.org/docs/bitc/spec.html. Last accessed June 15, 2010.Google Scholar
- }}D. Steinitz. Exporting a type class for type signatures. http://www.haskell.org/pipermail/haskell-cafe/2008-November/050409.html, November 2008.Google Scholar
- }}M. Sulzmann, G. J. Duck, S. Peyton Jones, and P. J. Stuckey. Understanding functional dependencies via constraint handling rules. JFP, 17(1):83--129, 2007. Google Scholar
Digital Library
- }}W. Swierstra. Data types à la carte. JFP, 18(04):423--436, 2008. Google Scholar
Digital Library
- }}D. M. Volpano and G. S. Smith. On the complexity of ML typeability with overloading. In FPCA '91, pages 15--28, Cambridge, Massachusetts, USA, 1991. Springer-Verlag. Google Scholar
Digital Library
- }}P.Wadler. The expression problem. http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt, 1998.Google Scholar
- }}P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In POPL '89, pages 60--76, Austin, Texas, USA, 1989. ACM. Google Scholar
Digital Library
Index Terms
Instance chains: type class programming without overlapping instances
Recommendations
Instance chains: type class programming without overlapping instances
ICFP '10: Proceedings of the 15th ACM SIGPLAN international conference on Functional programmingType 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 ...
Type families with class, type classes with family
Haskell '15: Proceedings of the 2015 ACM SIGPLAN Symposium on HaskellType classes and type families are key ingredients in Haskell programming. Type classes were introduced to deal with ad-hoc polymorphism, although with the introduction of functional dependencies, their use expanded to type-level programming. Type ...
Type families with class, type classes with family
Haskell '15Type classes and type families are key ingredients in Haskell programming. Type classes were introduced to deal with ad-hoc polymorphism, although with the introduction of functional dependencies, their use expanded to type-level programming. Type ...







Comments