-
Notifications
You must be signed in to change notification settings - Fork 39
Maybe
Yehonathan Sharvit edited this page Apr 14, 2021
·
2 revisions
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.
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:
- Functions that require the presence of the field (e.g. tax-related functions)
- Functions that don't care about the field at all (e.g. function that calculates the full name of a person)
- Functions that handle in a different way the presence and the absence of the field (e.g. functions that serialize person's data)