Promise.cast and Promise.resolve

Sébastien Cevey seb.cevey at
Wed Jan 29 04:04:03 PST 2014

On 29 Jan 2014 03:42, "Brendan Eich" <brendan at> wrote:

> And so we will go with 'chain'.

I assume it has been pointed out before that Underscore/LoDash have
popularised their own "chain" function/concept?

Hopefully it's distant enough from Promise-world to alleviate most
confusion, but I thought I'd point it out for completeness.

On the flatMap name, as a Scala developer, I find it quite conveniently
describes the "flattening" nature of the operation, although it only really
works thanks to the parallel with map:

M[A]#map(f: A => B): M[B]
M[A]#flatMap(f: A => M[B]): M[B]
(not M[M[B]] as it would with map - hence the "flat")

But given that 'then' is a sort of a mix of map/flatMap (and flatThen is
terrible), I don't think there is an obvious parallel currently.

Seeing as flatMap/chain is being discussed though, have there been plans to
add a map method on Promises (that would map to a new Promise without
unwrapping returned promises)?

And have there been any discussion to add other monadic types to ES, eg
Option/Maybe, Try, etc, or to make existing types support more monadic
operations, eg Array.prototype.flatMap (or "chain"?).

Thanks, and sorry if this has been discussed before (is there any way to
"catch up" on such topics if it has, short of reading piles of minutes?).

On 29 January 2014 03:42, Brendan Eich <brendan at> wrote:

> Quildreen Motta wrote:
>> I suppose using names that don't give you a hint of the meaning of the
>> operation fits perfectly Haskell's (and Scalaz's) "Avoid Success At All
>> Costs" tradition
> lulz.
> And so we will go with 'chain'.
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at

Sébastien Cevey
Software Developer

Please consider the environment before printing this email.

On your mobile, download the Guardian iPhone app and our iPad edition   
Save up to 57% by subscribing to the Guardian and Observer - choose the papers you want and get full digital access.

This e-mail and all attachments are confidential and may also
be privileged. If you are not the named recipient, please notify
the sender and delete the e-mail and all attachments immediately.
Do not disclose the contents to another person. You may not use
the information for any purpose, or store, or copy, it in any way.
Guardian News & Media Limited is not liable for any computer
viruses or other material transmitted with or as part of this
e-mail. You should employ virus checking software.
Guardian News & Media Limited
A member of Guardian Media Group plc
Registered Office
PO Box 68164
Kings Place
90 York Way
Registered in England Number 908396


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list