Affiliation:
1. Utrecht University, Utrecht, Netherlands
2. Utrecht University, Utrecht, and Open University of the Netherlands, Heerlen, Netherlands
Abstract
Haskell's
deriving
mechanism supports the automatic generation of instances for a number of functions. The Haskell 98 Report only specifies how to generate instances for the
Eq, Ord, Enum, Bounded, Show
, and
Read
classes. The description of how to generate instances is largely informal. The generation of instances imposes restrictions on the shape of datatypes, depending on the particular class to derive. As a consequence, the portability of instances across different compilers is not guaranteed.
We propose a new approach to Haskell's
deriving
mechanism, which allows users to specify how to derive arbitrary class instances using standard datatype-generic programming techniques. Generic functions, including the methods from six standard Haskell 98 derivable classes, can be specified entirely within Haskell 98 plus multi-parameter type classes, making them lightweight and portable. We can also express
Functor, Typeable
, and many other derivable classes with our technique. We implemented our
deriving
mechanism together with many new derivable classes in the Utrecht Haskell Compiler.
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Reference25 articles.
1. LNCS;Backhouse Roland,1999
2. }}Manuel M. T. Chakravarty Gabriel C. Ditu and Roman Leshchinskiy. Instant generics: Fast and easy 2009. Draft version. }}Manuel M. T. Chakravarty Gabriel C. Ditu and Roman Leshchinskiy. Instant generics: Fast and easy 2009. Draft version.
3. The architecture of the Utrecht Haskell compiler
Cited by
36 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献