Sciweavers

HASKELL
2006
ACM

Polymorphic variants in Haskell

14 years 5 months ago
Polymorphic variants in Haskell
In languages that support polymorphic variants, a single variant value can be passed to many contexts that accept different sets of constructors. Polymorphic variants are potentially useful for application domains such as interpreters, graphical user interface (GUI) libraries and database interfaces, where the number of necessary constructors cannot be determined in advance. The type system of Haskell, when extended with parametric type classes (or multi-parameter type classes with functional dependencies), has enough power to mimic polymorphic variants. This paper, first, explains how to encode polymorphic variants in Haskell’s type system (Haskell 98 + popular extensions). However, this encoding of polymorphic variants are rarely used in practice. This is probably because it is quite tedious for programmers to write mimic codes by hand and because the problem of ambiguity would embarrass programmers. Therefore, the paper proposes an extension of Haskell’s type classes that sup...
Koji Kagawa
Added 13 Jun 2010
Updated 13 Jun 2010
Type Conference
Year 2006
Where HASKELL
Authors Koji Kagawa
Comments (0)