by arciini · 4y ago · 0 comments
Ultimately, that's very similar to what old-school ways of declaring Promises do in Javascript. You're creating a data structure that you then attach a new function to execute with the results.
What we talk about when we have about monads is the highly generic interface coupled with the highly generic combinators. This is not something shared by arrays and promises. In other words, none of them are monads in any practically meaningful sense.
It's not "practically meaningless"; it's depth-first-search logic programming (as per How to Replace Failure by a List of Successes https://rkrishnan.org/files/wadler-1985.pdf )
Yes, and monadic code suffers from the same problem, that's why Haskell has do-notation
do
b <- fun1 a
c <- fun2 b
pure c -- using Purescript's pure instead of Haskell's `return`
instead of bind(fun1, (a) => bind(fun2, (b) => pure(b)))