Fuzion Logo
flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

infix >>=

🌌option.infix >>=

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.