Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Peter Jaszkowiak
This operator doesn't make any sense to me. It has to know not only the immediate expression to its left and/or right like normal operators. It's **absolutely** not a unary operator, as it has to have information about every outer operator. It's almost an inverted operator in that sense. If

Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Bryant Petersen
An expression which contains a `then` operator is not run synchronously. It does not run until its `then` expressions are resolved. It is like the body of a callback function, since the statements following it will most likely run before it does. The way I would implement this is by having

Re: Function composition vs pipeline

2018-03-03 Thread Isiah Meadows
Just thought I'd point out that the proposal itself entertains the possibility of a corresponding composition proposal [1]. Also, in my proposal, one of my "potential expansions" [2] would open a generic door for "lifting" over a type, addressing the concern of extensibility. (It's not ideal, and

Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Tab Atkins Jr.
On Sat, Mar 3, 2018 at 1:04 AM, Bryant Petersen wrote: > The purpose of `await` is to allow synchronous execution within an > async function. > > The purpose of `then` is to make it easier to manipulate the promises > as if they were normal values. It is much closer to >

Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Bryant Petersen
The purpose of `await` is to allow synchronous execution within an async function. The purpose of `then` is to make it easier to manipulate the promises as if they were normal values. It is much closer to `Promise.prototype.then` than to `await`, since it does not prevent the statements following

Re: Proposal: then operator for easier promise manipulation

2018-03-03 Thread Peter Jaszkowiak
Why not just use async/await then? Seems like if you were to replace `then` with `await` in your top example it would work exactly as you want (as long as it's in an async function). On Sat, Mar 3, 2018 at 1:06 AM, Bryant Petersen wrote: > I've put the details here:

Proposal: then operator for easier promise manipulation

2018-03-03 Thread Bryant Petersen
I've put the details here: https://github.com/bwpetersen/proposal-then-operator The basic idea is that the `then` operator would allow you to manipulate a promise as if it were its resolved value. Expressions containing `then` become similar to an `onFulfillment` handler. Here is an example: