Lightweight Extensible Records for Haskell
Mark P. Jones, Simon Peyton Jones · 1999
Early versions of Haskell provied only a positional notation to build and take apart user-defined datatypes. This positional notation is awkward and error-prone when dealing with datatypes that have more than a couple of components, so later versions of Haskell introduced a mechanism for labeled fields that allows components to be set and extracted by name. While this has been useful in practice, it also has several significant problems; for example, no field name can be used in more than one datatype. In this paper, we present a concrete proposal for replacing the labeled-field mechanisms of Haskell 98 with a more flexible system of records that avoids the problems mentioned above. With a theoretical foundation in the earlier work of Gaster and Jones, our system offers lightweight, extensible records and a complement of polymorphic operations for manipulating them. On a more concrete level, our proposal is a direct descendent of the Trex implementation ("typed records with extensibility") i...