Re:Abstraction, intuition, and the “monad tutorial fallacy” ...
by pharmakom on Friday October 01, 2021 @02:57AM
(#28715473)
Promise<Promise<T>> is collapsed to Promise<T> automatically, which violates monad laws.
[ Parent
| on HN ]
Re:Abstraction, intuition, and the “monad tutorial fallacy” ...
by eyelidlessness on Friday October 01, 2021 @11:05AM
(#28719401)
What’s interesting is this seems to say the exact opposite of what the other direct response says. But I also don’t think this is exactly true.
Promise.resolve(
Promise.resolve('foo')
)
At runtime is Promise<Promise<string>>. It only collapses when chained to then (or await’ed), just as in the sibling comment’s flatMap example.