Answer the question
In order to leave comments, you need to log in
What is the difference between promises and monads?
I'm not very in theory, so it's interesting.
After all, the same chain of function calls, each subsequent sending result and information about success or failure.
Answer the question
In order to leave comments, you need to log in
Promise is one of the monads where bind (>>=), simplified, makes a new promise from a promise and from a subsequent function, which waits for the first promise to be fulfilled and passes the result to the next function. As a result, control is returned to the calling function on the first wait.
But there are other monads. For example Either , which allows you to issue an "error", ie. breaking the entire chain of calculations at the first error. Or Maybe, which behaves similarly to Either, but not with some erroneous value being returned, but simply stopping at the first fail. The list is also a monad, where the subsequent function will be evaluated on each element, and the results will be concatenated.
Promise is not a call chain. Promise (translated as "promise") - the function tells you that at this particular moment it cannot return the result to you, but it PROMISES that after a while it will return it to you. Or return an error. Promise is a tool that allows asynchronous code to exist more or less tolerably.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question