Closed stereobooster closed 3 years ago
I didn't want to have to explain a bunch of types that aren't built into JavaScript.
Promise.then is actually both the map and flatmap interface which I think makes using it for the explanation confusing
There is a section on Maybe which has chain/flatmap used. Maybe it's worth linking from the monad section
Promise.then is actually both the map and flatmap interface which I think makes using it for the explanation confusing
I didn't know that. Worth to mention that fact.
When onFulfilled
returns promise (generally "thenable" object) then then
works as flatMap
, If returned value is not promise then it works as map
.
Links: https://promisesaplus.com/, https://gist.github.com/briancavalier/3296186
We've added the name aliases for chain. I'm not comfortable saying that then
is equivalent to map
. I think we should add a section on Future/Promise/Task to explain the functor aspects of those types.
Add examples from real world examples.
For example section on monads. Alternative name for
chain
isflatMap
(orflat_map
orflatmap
). Real world example is streams for instance in highland.For example section on functors. Real world example: of course
Array
. But alsoStreams
andPromises
. InPromises
map
is calledthen
.I believe this can be helpful.