3 ms·
Already locked for editing. For anyone reading this after the fact, I'd restate as follows. There are types called Sum Types which are formed by combining othe
by tmountain 8y ago
Already locked for editing. For anyone reading this after the fact, I'd restate as follows.
There are types called Sum Types which are formed by combining other types. Each value associated with a Sum Type is associated with a constructor (label for the value) and zero or more values associated with that constructor.
As an example, a Maybe type could be defined to represent two states as follows:
data Maybe a = Just a | Nothing
When a value is present, it can be represented as:
Just 3, Just "Hello", Just [1,2,3], etc.
While missing values can be represented as:
Nothing
And yeah to be clear, we are talking about immutable values. Boxes that carry around some value (or lack thereof) that never change.