This RFC is about adding "lambda-tasks" which are tasks that can be written inline, like lambda-functions. Currently it is possible to write tasks and functions as top-level items.
fun succ(x: i32): i32 {
x + 1
}
task Succ(): ~i32 -> ~i32 {
loop {
on event => emit succ(event)
}
}
It is also possible to write lambda-functions:
task Map(f: fun(i32):i32): ~i32 -> ~i32 {
loop {
on event => emit f(event)
}
}
fun test(s: ~i32): ~i32 {
s | Map(fun(event): event + 1)
}
However it is currently not possible to write tasks as inline. A motivation for adding this feature is it will reduce the verbosity of writing simple tasks. Furthermore, this is a feature which Ray does not support. I propose the following addition:
Expr ::=
| task ( <Params> ) : <Expr>
| ...
Lambda-tasks have one input and output stream. The type of a lambda-task is inferred from its context. This allows tasks to be constructed as expressions:
fun test(s: ~i32): ~i32 {
s | task(): loop {
on event => emit event + 1
}
}
The above will desugar into the following:
task <anonymous>() {
loop {
on event => emit event + 1
}
}
fun test(s: ~i32): ~i32 {
s | <anonymous>()
}
We can apply lambda-lifting to also allow tasks capture variables.
This RFC is about adding "lambda-tasks" which are tasks that can be written inline, like lambda-functions. Currently it is possible to write tasks and functions as top-level items.
It is also possible to write lambda-functions:
However it is currently not possible to write tasks as inline. A motivation for adding this feature is it will reduce the verbosity of writing simple tasks. Furthermore, this is a feature which Ray does not support. I propose the following addition:
Lambda-tasks have one input and output stream. The type of a lambda-task is inferred from its context. This allows tasks to be constructed as expressions:
The above will desugar into the following:
We can apply lambda-lifting to also allow tasks capture variables.