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.
-
Show this thread
-
Replying to @ValueOfType
Wanna teach me monads? I’ve stared at them before, but the understanding slides right off my brain, so far
1 reply 0 retweets 1 like -
Replying to @robcobbable
Sure, what's your background? Does the "convenient notation" part in the gif make sense to you? https://www.bram.us/wordpress/wp-content/uploads/2017/05/js-callbacks-promises-asyncawait.gif …
1 reply 0 retweets 1 like -
Replying to @ValueOfType
I’ve see plenty of javascript and the example makes sense. Background is a good bit of cs and software, mostly dynamic languages but some flow/typescript and typed languages here and there
1 reply 0 retweets 0 likes -
Replying to @robcobbable
Great. But using >>= in Haskell is still more mysterious than using .then in JS, or what do you feel unsure about?
1 reply 0 retweets 0 likes -
Replying to @ValueOfType @robcobbable
What I don't get is which part the word monad refers to
1 reply 0 retweets 2 likes -
Replying to @derelbenkoenig @robcobbable
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.
1 reply 0 retweets 0 likes -
Replying to @ValueOfType @derelbenkoenig
Probably need to meditate on that a bit. What would definitions of return and >>= look like for a js Promise? Is ‘then’ ‘>>=‘?
1 reply 0 retweets 0 likes -
Replying to @robcobbable @derelbenkoenig
Yes. For return: return = x => Promise.resolve(x);
1 reply 0 retweets 0 likes -
Replying to @ValueOfType @derelbenkoenig
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) ??
1 reply 0 retweets 0 likes
bind is flatMap
-
-
Replying to @ValueOfType @derelbenkoenig
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
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
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.