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
- Manuel M. T. Chakravarty, Gabriele Keller, and Simon Peyton Jones. Associated type synonyms. In ICFP '05.]] Google Scholar
Digital Library
- Manuel M. T. Chakravarty, Gabriele Keller, Simon Peyton Jones, and Simon Marlow. Associated types with class. In POPL '05.]] Google Scholar
Digital Library
- Luis Damas and Robin Milner. Principal type schemes for functional programs. In POPL '82.]] Google Scholar
Digital Library
- Derek Dreyer. Understanding and Evolving the ML Module System. PhD thesis, Carnegie Mellon University, Pittsburgh, PA, May 2005.]] Google Scholar
Digital Library
- 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 Scholar
- Derek Dreyer, Karl Crary, and Robert Harper. A type system for higher-order modules. In POPL '03.]] Google Scholar
Digital Library
- 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 Scholar
- Robert Harper, John C. Mitchell, and Eugenio Moggi. Higher-order modules and the phase distinction. In POPL '90.]] Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Mark P. Jones. Simplifying and improving qualified types. In FPCA '95.]] Google Scholar
Digital Library
- Mark P. Jones. A theory of qualified types. In ESOP '92.]] Google Scholar
Digital Library
- Mark P. Jones. Type classes with functional dependencies. In ESOP'00.]] Google Scholar
Digital Library
- Mark P. Jones. Using parameterized signatures to express modular structure. In POPL '96.]] Google Scholar
Digital Library
- Mark P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, 1994.]] Google Scholar
Digital Library
- Mark P. Jones. A system of constructor classes: Overloading and implicit higher-order polymorphism. Journal of Functional Programming, 5(1), 1995.]]Google Scholar
Cross Ref
- Wolfram Kahl and Jan Scheffczyk. Named instances for Haskell type classes. In Haskell Workshop, 2001.]]Google Scholar
- David MacQueen. Modules for Standard ML. In LFP '84.]] Google Scholar
Digital Library
- Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The Definition of Standard ML (Revised). MIT Press, 1997.]] Google Scholar
Digital Library
- Simon Peyton Jones et al. Haskell 98 language and libraries: the revised report. Journal of Functional Programming, 13(1), 2003.]]Google Scholar
- Gerhard Schneider. ML mit Typklassen. Master's thesis, June 2000.]]Google Scholar
- Jeremy Siek. A Language for Generic Programming. PhD thesis, Indiana University, August 2005.]] Google Scholar
Digital Library
- Jeremy Siek and Andrew Lumsdaine. Essential language support for generic programming. In PLDI'05.]] Google Scholar
Digital Library
- P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad-hoc. In POPL '89.]] Google Scholar
Digital Library
- 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 Scholar
Index Terms
Modular type classes





Comments