VariantΒΆ
Variant is a sum type, i.e. a wrapper for a value which can be of different
types. For instance in the following code x is a variant whose value can be
an Int, a Float or a String:
import Haskus.Utils.Variant
x :: V '[Int,Float,String]
We use a type-level list of types to statically constrain the possible value
types. Compared to usual sum types (e.g. Either Int Float) it allows us to
have variants which can contain any number of types and to manipulate
(extend/filter/etc.) the list in a type-safe way and without requiring new data
types.
See also