Pre-conj Prep: Jeanine Adkisson

Talk: Variants are Not Unions

Jeanine Adkisson's talk at the conj is about using Variants in Clojure. Variants are a way to represent different cases of value that belong to the same type. For instance, a linked list type might be represented as two cases: an empty list and a tuple of an element and a list. A tag distinguishes between the two cases.

Background

In a dynamically typed language, we often play fast and loose with type. For instance, we might write a function with a giant cond statement in the body that does little more than switch on type. But how do we know we've checked all the types we need to? Variants solve this problem.

Variants are a key feature of Haskell and ML. Adkisson mentions that there is no standard way of representing them in Clojure, which is true, though several commonplace conventions exist for getting some of the uses of Variants. However, there is not a common convention for noting all of the possible tags and ensuring that all cases are covered in a conditional. The talk description also mentions core.typed (a type system for Clojure, which does not have Variants) and Datomic (a database written by the creators of Clojure).

Why it matters

Adding Variants to Clojure is a good example of the Clojure community's excitement about borrowing good ideas from a variety of languages. And the fact that a new kind of type can be introduced that works in the dynamic language, a type system, and a database is promising for the future of idea borrowing in Clojure.

About Jeanine Adkisson

Twitter - Github - Blog