Re: monadic extension to do-notation

2016-02-22 Thread Brendan Eich
We'll get it on the next TC39 meeting's agenda. /be On Mon, Feb 22, 2016 at 5:28 PM Alan Johnson wrote: > If this is done, please go with `async do { … await … }`. May as well > reuse existing syntax as much as possible. As mentioned, `<-` is > problematic both from the

Re: monadic extension to do-notation

2016-02-22 Thread Alan Johnson
If this is done, please go with `async do { … await … }`. May as well reuse existing syntax as much as possible. As mentioned, `<-` is problematic both from the standpoint of conflict with existing operators and incomplete analogy with Haskell. If the result should be Promise-ified, best to

Re: monadic extension to do-notation

2016-02-09 Thread Tab Atkins Jr.
On Sun, Feb 7, 2016 at 9:07 AM, Raphael Mu wrote: > The ES Promise is an instance of Monad, a property that implies a much more > concise and expressive syntax for using Promise, by exploiting its monadic > properties. I've seen a lot of people complain about Promises

Re: monadic extension to do-notation

2016-02-09 Thread /#!/JoePea
On Tue, Feb 9, 2016 at 10:28 PM, Isiah Meadows wrote: > let finalPromise = (async () => { > let x = await promiseA > let y = await promiseB > let c = f(a, b) > return g(a, b, c) > })() I think it's important to keep the async/await keywords because they give a

Re: monadic extension to do-notation

2016-02-09 Thread Isiah Meadows
There is kind of a `do`-like syntax for Promises: async functions. To borrow Tab's example: ```js let finalPromise = (async () => { let x = await promiseA let y = await promiseB let c = f(a, b) return g(a, b, c) })() // or in parallel let finalPromise = (async () => { let [x, y] =

Re: monadic extension to do-notation

2016-02-09 Thread Isiah Meadows
I see little to be gained, and it's not clear that it's in a different context. Plus, assuming your editor balances parentheses and auto indents, I see no more than about 8-10 keystrokes saved for something that isn't super frequently used. Not saying it's a bad idea, but ES has gotten to the

Re: monadic extension to do-notation

2016-02-07 Thread Kevin Smith
Why not just use await within `async do`? On 12:19PM, Sun, Feb 7, 2016 Rick Waldron wrote: > What does this do? > > > let finalPromise = do { > let a; > a <- b; > } > > > Currently, that's an expression that means "a less than negated b" > > Rick > > On Sun, Feb 7, 2016

Re: monadic extension to do-notation

2016-02-07 Thread Mark S. Miller
Since the non-monadic way won, I don't know that it is worth arguing about why. But it is ergonomic issues much deeper than convenience, and much more important than compatibility with existing libraries -- even if those two were adequate considerations by themselves. The behavior of promises was

Re: monadic extension to do-notation

2016-02-07 Thread Brendan Eich
And draft ES6 tried for monadic, but compatibility with Promises libraries (more than "convenience") prevailed. /be On Sun, Feb 7, 2016 at 11:35 AM Raphael Mu wrote: > In theory it's possible, but Promise.resolve automatically joins Promises > for the sake of

Re: monadic extension to do-notation

2016-02-07 Thread Brendan Eich
M extension that performed auto > boxing/unboxing on Promises, achieving a similar result without the need > for additional syntactic constructions > > > -- > > monadic extension to do-notation > > From: Raphael Mu <encryptedre...@gmail.com> > > Date: 7 Feb,

Re: monadic extension to do-notation

2016-02-07 Thread Rick Waldron
What does this do? let finalPromise = do { let a; a <- b; } Currently, that's an expression that means "a less than negated b" Rick On Sun, Feb 7, 2016 at 12:07 PM Raphael Mu wrote: > The ES Promise is an instance of Monad, a property that implies a much > more

Re: monadic extension to do-notation

2016-02-07 Thread Raphael Mu
In theory it's possible, but Promise.resolve automatically joins Promises for the sake of ergonomics. On Sun, Feb 7, 2016 at 1:15 PM Jordan Harband wrote: > How is Promise an instance of Monad, if you can't ever have a Promise of a > Promise? > > On Sun, Feb 7, 2016 at 9:59

monadic extension to do-notation

2016-02-07 Thread Raphael Mu
The ES Promise is an instance of Monad, a property that implies a much more concise and expressive syntax for using Promise, by exploiting its monadic properties. I've seen a lot of people complain about Promises having too clumsy a syntax, and likewise for async/await. We now have the

Re: monadic extension to do-notation

2016-02-07 Thread Raphael Mu
The `a < -b` issue could be solved by using a different operator, like ` wrote: > Why not just use await within `async do`? > > On 12:19PM, Sun, Feb 7, 2016 Rick Waldron wrote: > >> What does this do? >> >> >> let finalPromise = do { >> let a; >> a <- b; >> } >> >> >>

RE: monadic extension to do-notation

2016-02-07 Thread Mat At Bread
ons -- monadic extension to do-notation From: Raphael Mu <encryptedre...@gmail.com> Date: 7 Feb, 17:07 To: es-discuss@mozilla.org The ES Promise is an instance of Monad, a property that implies a much more concise and expressive syntax for using Promise, by exploiting its monadic propert

Re: monadic extension to do-notation

2016-02-07 Thread Jordan Harband
How is Promise an instance of Monad, if you can't ever have a Promise of a Promise? On Sun, Feb 7, 2016 at 9:59 AM, Raphael Mu wrote: > The `a < -b` issue could be solved by using a different operator, like > ` > On Sun, Feb 7, 2016 at 12:35 PM Kevin Smith