Docs
Result and option
Produce and match result / option shapes.
Result
A function with an error-return path has a result shape. ! returns the error payload from the current function and leaves the process running. File-scope ! is sem-error-return. ^ v is ok. ! e is err.
/ std/io
/ std/str
$ checked = (x) {
? x < 0 {
! 'negative'
}
^ x
}
| checked(7) {
$ value {
io.print(str.from_int(value))
}
! error {
io.print(error)
}
}Option
An option-shaped function returns ^ v for some and bare ^ for none.
/ std/io
/ std/str
$ maybe = (x) {
? x == 0 {
^
}
^ x
}
| maybe(7) {
$ value {
io.print(str.from_int(value))
}
: {
io.print('empty')
}
}Rules
A result match uses $ name for ok and ! name for err. An option match uses $ name for some and : for none. Leaving either shape unhandled is a compile error; there is no silent discard or separate try form.