People who have trouble understanding monads usually don't have any problem with callbacks. Because the computational context "some as usual, except in the near future" is familiar to them.
Great. But using >>= in Haskell is still more mysterious than using .then in JS, or what do you feel unsure about?
-
-
What I don't get is which part the word monad refers to
-
Maybe it is difficult to see it as a thing because it is more like a design pattern, except fully incarnated (into a type constructer, two generic functions and three laws). The monad design pattern is about sequencing computations that exist in some computational context.
-
Probably need to meditate on that a bit. What would definitions of return and >>= look like for a js Promise? Is ‘then’ ‘>>=‘?
-
Yes. For return: return = x => Promise.resolve(x);
-
Okay, I think I’m starting to see it. Continuation is definitely easier to see than Maybe or List. List in js is effectively return: a => [a] bind: g => [a].map(g) ??
-
bind is flatMap
-
Gah, I think I’m getting my head turned around by this example because js promises ‘then’ callback is allowed to return either a value or a promise
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.