|
|
|
|
|
by binary132
243 days ago
|
|
This is misleading IMO because Promise is a particular kind of monad but in general monads don’t necessarily have anything to do with asynchrony. It is a useful example though because some people are more familiar with the API of promises. I might have some inaccuracies in how I state this since I’m not from a functional programming background, but I think of monads as an abstraction of chaining functions over a value such that each returned value can specify what further transformations it supports, and particularly in such a way that generic transformations (like sequence reversal) can easily be applied, and errors or empty values can be accounted for within the control flow. I think sometimes people call this a “fluent API”, but I would never call it “a generalization of callbacks” or of promises. Anyway there’s a much more mathematically precise way of stating it but this is my intuitive caveman way of thinking about it. |
|