Graph explorer

Variations on Variants

Extensible variants improve the modularity and expressiveness of programming languages: they allow program functionality to be decomposed into independent blocks, and allow seamless extension of existing code with both new cases of existing data types and new operations over those data types. This paper considers three approaches to providing extensible variants in Haskell. Row typing is a long understood mechanism for typing extensible records and variants, but its adoption would require extension of Haskell's core type system. Alternatively, we might hope to encode extensible variants in terms of existing mechanisms, such as type classes. We describe an encoding of extensible variants using instance chains, a proposed extension of the class system. Unlike many previous encodings of extensible variants, ours does not require the definition of a new type class for each function that consumes variants. Finally, we translate our encoding to use closed type families, an existing feature of GHC. Doing so demonstrates the interpretation of instances chains and functional dependencies in closed type families. One concern with encodings like ours is how completely they match the encod

3 nodes2 linksoverview mapVariations on Variants
3 nodes2 links
Variations on Variants3 visible / 3 total nodes / 2 links
AuthorshipTopic signalWVariations on Variantspreprint / 2016AJ. Garrett MorrisResearcherTProgramming Languages1239 works
PaperSignal 102 links

Variations on Variants

preprint / 2016

Open