by smadge · 8y ago · 0 comments
“To simplify the use of callbacks both syntactically and conceptually, Scala provides combinators such as flatMap, foreach, and filter used to compose futures in a non-blocking way.”
‘flatMap’ is exactly the bind function for the promise monad. It doesn’t have to explicitly implement some monad interface to be a monad, it just is.
One more time - Futures are orthogonal to Monads. They may be viewed as such, but it is not necessary. Having only flatMap is sufficient for a strict language.
Something that implements a "monad interface" (e.g. has pure, map and flatMap methods) doesn't compulsorily have to be a monad.
A monad has to obey the monad laws to be one.
Scala's Future is not a monad per se:
https://stackoverflow.com/questions/27454798/is-future-in-sc...