TR-2006-03
Modular Type Classes
Derek Dreyer; Robert Harper; Manuel M.T. Chakravarty; Gabriele Keller. 14 April, 2006.
Communicated by Robby Findler.
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. The modular setting offers several
benefits: programmers have explicit control over which type class
instances are available for use by type inference in a given scope,
class hierarchies are expressible in terms of module hierarchies, and
extensions to Haskell such as associated type synonyms arise naturally
as uses of existing module-language constructs. We formalize our
approach as an elaboration relation in the style of Harper and Stone,
and provide a sound type inference algorithm as a guide to
implementation.
Original Document
The original document is available in PDF (uploaded 14 April, 2006 by
Robby Findler).