option
🌌option
option represents an optional value of type T
synonyme for infix >>=
converts option to a string
returns the result of $T for an option containing an instance
of T, alternatively returns $nil for an option that is nil.
redefines Object.asString:
monadic operator
Same as non-generic >>=, but also maps to a different type B.
unwraps an option that is known to contain a value
this can only be called in cases where it is known for sure that this option
is not nil. A runtime error will be created otherwise.
monadic operator
This is handy to implement functions on optional values. As an example,
take an option<string> and you would like to add a filename suffix to
this string if it is present. Then you can do this as follows:
addTxt(o option<string>) => o >>= s -> option<string> is s + ".txt"
NYI: With better type inference and syntactic sugar, this should be
addTxt(o option<string>) => o >>= s -> s + ".txt"
NYI: Should maybe have generic parameter <B> and result in option<B>
redefines monad.infix >>=:
monadic operator within the same monad
Apply f to elements of type A and re-wrap them in this monad.
map this option using f, i.e., map nil to nil and any value v to f v
short-hand postfix operator for 'isNil'
short-hand postfix operator for 'exists'