One thing that's very hard to do in job writing is do muliple steps in one.
each is the usual usecase, where I want to do:
each($.data, get, fn, post)
Where what I really want in the each is a little pipeline which processes each item through multiple operations
I can do this today with promises:
each($.data, get.then(fn).then(post))
But it's ugly, the compiler creaks, and error handling isn't great
You can also use combine, which is cool but no-one knows about it:
each($.data, combine(get(), fn(), post()))
I'm just wondering if we can do some syntactic sugar for combine, like:
each($.data, [get, fn, post])
But we probably can't distinguish this piping sort of expression from an array.
What if we used something more like piping?
each($.data, get |> fn |> post)
each($.data, get | fn | post)
each($.data, get > fn > post)
each($.data, @[get,fn , post])
Not terribly neat or intuitive.
using a pipe is OK but the synax isn't reserved, so how would I catch it?
JS does have a proposal for a pipeline operator: https://github.com/tc39/proposal-pipeline-operator
So it's this then:
each($.data, get |> fn |> post)
The compiler detects the chain and compiles it to:
each($.data, combine(get, fn, post))
You cannot use the pipe operator inside a block statement. Use it only in place of an operation.
One thing that's very hard to do in job writing is do muliple steps in one.
eachis the usual usecase, where I want to do:Where what I really want in the each is a little pipeline which processes each item through multiple operations
I can do this today with promises:
But it's ugly, the compiler creaks, and error handling isn't great
You can also use combine, which is cool but no-one knows about it:
I'm just wondering if we can do some syntactic sugar for combine, like:
But we probably can't distinguish this piping sort of expression from an array.
What if we used something more like piping?
Not terribly neat or intuitive.
using a pipe is OK but the synax isn't reserved, so how would I catch it?
JS does have a proposal for a pipeline operator: https://github.com/tc39/proposal-pipeline-operator
So it's this then:
The compiler detects the chain and compiles it to:
You cannot use the pipe operator inside a block statement. Use it only in place of an operation.