In a similar way to list('a), the Pervasives module also provides a data type, option('a). This time let's look at its real definition, because there's no syntactic sugar for it, as follows:
type option('a) = Some('a) | None;
In some ways, this is a simpler data type than the list. Its real utility comes from the meaning we give to the variant cases:
- Some('a): Represents a value that is present and that is known
- None: Represents a value that is absent and is unknown
In Reason, and some other languages, there is no concept of a null value, so this option type is used to represent that a value is present or absent. Whenever we'd use null, we can use options instead, with the benefit that optionality (the property that some value may be present or not) is captured in the type system, instead...