An optional value — either present, carrying a value, or absent. Because it is a real generic union rather than a nullable flag, it nests cleanly and must be checked before its value can be used. Construct one with Collection.Optional.present or Collection.Optional.absent.
A value that is either present, carrying a value, or absent. Because it is a real generic union rather than a nullable flag, it nests cleanly: a Collection.Optional(Collection.Optional(Text)) can tell absent apart from present-but-empty. Construct one with Collection.Optional.present or Collection.Optional.absent.
Unwraps the optional, falling back to "guest" when it is absent.
Collection.Optional.If
Runs a callback with the contained value when an optional is present, and does nothing when it is absent.
Generics
Name
Description
ValueType
The type of value the optional may hold.
Parameters
Name
Type
Description
optionalValue
Collection.Optional(ValueType)
The optional to test.
Holes
Name
Returns
Description
callback
nothing
Run once with the unwrapped value when the optional is present; never run when it is absent.
Inputs
Name
Type
Description
value
ValueType
The value the optional holds, unwrapped.
Example
LETCollection.Optional(Text)maybeName=Collection.Optional.present"Ada"// Run the callback only when the optional is presentCollection.Optional.IfmaybeNameINPUTTextnameUi.Content.Textname
Constructs an optional holding "Ada"; Collection.Optional.If then runs the callback with the unwrapped value bound to name. When the optional is absent, the callback never runs.
Collection.Optional.IfNot
Runs a callback when an optional is absent, and does nothing when it is present.
Generics
Name
Description
ValueType
The type of value the optional may hold.
Parameters
Name
Type
Description
optionalValue
Collection.Optional(ValueType)
The optional to test.
Holes
Name
Returns
Description
callback
nothing
Run once when the optional is absent; never run when it is present. It receives no inputs.
Example
Collection.Optional.IfNotmaybeNameUi.Content.Text"No name yet"
Shows the placeholder text only while maybeName is absent.
Collection.Optional.IsAbsent
Yields yes when the optional carries no value.
Generics
Name
Description
ValueType
The type of value the optional may hold.
Parameters
Name
Type
Description
optionalValue
Collection.Optional(ValueType)
The optional to test.
Returns
Returns Logic.Maybe — yes when absent, otherwise no — the negation of IsPresent.