A generic deriving mechanism for Haskell

A generic deriving mechanism for Haskell
复制标题

Haskell 的通用派生机制

DOI:
10.1145/1863523.1863529
复制
发表时间:
2010
影响因子:
2.3
通讯作者:
Andres Löh
Andres Löh
中科院分区:
心理学4区
文献类型:
--
作者:
José Pedro Magalhães;A. Dijkstra;J. Jeuring;Andres Löh

文献摘要

被引文献

相似文献

Haskell的得出机制支持许多功能的自动生成实例。 Haskell 98报告仅指定如何生成均衡器,ORD,ENUM,BOUNDED,BOUNDED,显示和阅读类的实例。关于如何生成实例的描述在很大程度上是非正式的。实例的生成对数据类型的形状施加了限制,具体取决于要得出的特定类别。结果,不能保证在不同编译器之间的实例可移植性。 我们为Haskell的衍生机制提出了一种新方法,该方法允许用户指定如何使用标准数据类型形式的编程技术来得出任意类实例。可以在Haskell 98加多参数类型类中完全指定的通用功能,包括六个标准Haskell 98衍生类别类的方法,使其轻巧且便携。我们还可以通过我们的技术表达函数,可拼写和许多其他可衍生的类。我们在UTRECHT HASKELL编译器中实施了衍生机制以及许多新的可衍生类。
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.