article

Modular type classes

Published:17 January 2007Publication History

Abstract

ML modules and Haskell type classes have proven to be highly effective tools for program structuring. Modules emphasize explicit configuration of program components and the use of data abstraction. Type classes emphasize implicit program construction and ad hoc polymorphism. In this paper, we show how the implicitly-typed style of type class programming may be supported within the framework of an explicitly-typed module language by viewing type classes as a particular mode of use of modules. This view offers a harmonious integration of modules and type classes, where type class features, such as class hierarchies and associated types, arise naturally as uses of existing module-language constructs, such as module hierarchies and type components. In addition, programmers have explicit control over which type class instances are available for use by type inference in a given scope. We formalize our approach as a Harper-Stone-style elaboration relation, and provide a sound type inference algorithm as a guide to implementation.

References

  1. Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. Associated type synonyms. In ICFP '05.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Manuel M. T. Chakravarty, Gabriele Keller, Simon Peyton Jones, and Simon Marlow. Associated types with class. In POPL '05.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Luis Damas and Robin Milner. Principal type schemes for functional programs. In POPL '82.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Derek Dreyer. Understanding and Evolving the ML Module System. PhD thesis, Carnegie Mellon University, Pittsburgh, PA, May 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Derek Dreyer and Matthias Blume. Principal type schemes for modular programs. Technical Report TR-2006-08, University of Chicago Comp. Sci. Dept., October 2006.]]Google ScholarGoogle Scholar
  6. Derek Dreyer, Karl Crary, and Robert Harper. A type system for higher-order modules. In POPL '03.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Derek Dreyer, Robert Harper, Manuel M.T. Chakravarty, and Gabriele Keller. Modular type classes. Technical Report TR-2006-09, University of Chicago Comp. Sci. Dept., October 2006.]]Google ScholarGoogle Scholar
  8. Robert Harper, John C. Mitchell, and Eugenio Moggi. Higher-order modules and the phase distinction. In POPL '90.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Robert Harper and Chris Stone. A type-theoretic interpretation of Standard ML. In G. Plotkin, C. Stirling, and M. Tofte, editors, Proof, Language, and Interaction: Essays in Honor of Robin Milner. MIT Press, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Mark P. Jones. Simplifying and improving qualified types. In FPCA '95.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Mark P. Jones. A theory of qualified types. In ESOP '92.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Mark P. Jones. Type classes with functional dependencies. In ESOP'00.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Mark P. Jones. Using parameterized signatures to express modular structure. In POPL '96.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Mark P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Mark P. Jones. A system of constructor classes: Overloading and implicit higher-order polymorphism. Journal of Functional Programming, 5(1), 1995.]]Google ScholarGoogle ScholarCross RefCross Ref
  16. Wolfram Kahl and Jan Scheffczyk. Named instances for Haskell type classes. In Haskell Workshop, 2001.]]Google ScholarGoogle Scholar
  17. David MacQueen. Modules for Standard ML. In LFP '84.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The Definition of Standard ML (Revised). MIT Press, 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Simon Peyton Jones et al. Haskell 98 language and libraries: the revised report. Journal of Functional Programming, 13(1), 2003.]]Google ScholarGoogle Scholar
  20. Gerhard Schneider. ML mit Typklassen. Master's thesis, June 2000.]]Google ScholarGoogle Scholar
  21. Jeremy Siek. A Language for Generic Programming. PhD thesis, Indiana University, August 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Jeremy Siek and Andrew Lumsdaine. Essential language support for generic programming. In PLDI'05.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad-hoc. In POPL '89.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Stefan Wehr. ML modules and Haskell type classes: A constructive comparison. Master's thesis, Albert-Ludwigs-Universität Freiburg, Institut für Informatik, 2005.]]Google ScholarGoogle Scholar

Index Terms

  1. Modular type classes

            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 42, Issue 1
              Proceedings of the 2007 POPL Conference
              January 2007
              379 pages
              ISSN:0362-1340
              EISSN:1558-1160
              DOI:10.1145/1190215
              Issue’s Table of Contents
              • cover image ACM Conferences
                POPL '07: Proceedings of the 34th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
                January 2007
                400 pages
                ISBN:1595935754
                DOI:10.1145/1190216

              Copyright © 2007 ACM

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 17 January 2007

              Check for updates

              Qualifiers

              • article

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader
            About Cookies On This Site

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

            Learn more

            Got it!