skip to main content
research-article

Instance chains: type class programming without overlapping instances

Published:27 September 2010Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

icfp-weds-1750-morris.mov

References

  1. }}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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. }}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 ScholarGoogle Scholar
  3. }}B. Heeren and J. Hage. Type class directives. In PADL '05, pages 253--267. Springer-Verlag, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. }}M. P. Jones. A theory of qualified types. In B. K. Bruckner, editor, ESOP '92, volume 582. Springer-Verlag, London, UK, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. }}M. P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. }}M. P. Jones. Type classes with functional dependencies. In ESOP 2000, pages 230--244, London, UK, 2000. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. }}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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. }}O. Kiselyov and R. Lämmel. Haskell's overlooked object system. Draft; Submitted for publication; online since 10 Sept. 2005.Google ScholarGoogle Scholar
  9. }}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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. }}D. Maier. The Theory of Relational Databases. Computer Science Press, 1983. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. }}J. G. Morris. Experience report: Using Hackage to inform language design. In Haskell '10, Baltimore, Maryland, USA, 2010. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. }}M. Neubauer, P. Thiemann, M. Gasbichler, and M. Sperber. A functional notation for functional dependencies. In Haskell '01, Firenze, Italy, September 2001.Google ScholarGoogle Scholar
  13. }}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 ScholarGoogle Scholar
  14. }}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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. }}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 ScholarGoogle Scholar
  16. }}D. Steinitz. Exporting a type class for type signatures. http://www.haskell.org/pipermail/haskell-cafe/2008-November/050409.html, November 2008.Google ScholarGoogle Scholar
  17. }}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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. }}W. Swierstra. Data types à la carte. JFP, 18(04):423--436, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. }}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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. }}P.Wadler. The expression problem. http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt, 1998.Google ScholarGoogle Scholar
  21. }}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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Instance chains: type class programming without overlapping instances

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 45, Issue 9
        ICFP '10
        September 2010
        382 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1932681
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP '10: Proceedings of the 15th ACM SIGPLAN international conference on Functional programming
          September 2010
          398 pages
          ISBN:9781605587943
          DOI:10.1145/1863543

        Copyright © 2010 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 27 September 2010

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      ePub

      View this article in ePub.

      View ePub
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!