Skip to content
Yehonathan Sharvit edited this page Apr 14, 2021 · 2 revisions

Maybe

Definition

Nothing is of type maybe something.

Maybe is a property of the aggregate not of the field. For example, in a record, a field may be there or not.

Example

It makes no sense to say that the type of the social security number of a person is maybe a string.

What makes sense is to say: in this map (that aggregates data about a person), the social security number may be present or not in the map. If it's present, it is a string.

Even more precise: this function receives as an argument a map where the social security number may be a string.

There are three kind of functions in regards to the present of the social security number in a map that represent a person:

  1. Functions that require the presence of the field (e.g. tax-related functions)
  2. Functions that don't care about the field at all (e.g. function that calculates the full name of a person)
  3. Functions that handle in a different way the presence and the absence of the field (e.g. functions that serialize person's data)

Clone this wiki locally