4 ms·
The Javascript example kind of confuses the solution with the problem. The convoluted syntax of the 'callback-hell' is the problem. Monads does not solve this p
by olavk 12y ago
The Javascript example kind of confuses the solution with the problem. The convoluted syntax of the 'callback-hell' is the problem. Monads does not solve this problem, rather the use of monads leads to that kind of syntax. The solution proposed for the syntactic mess is Haskells do-notation. Do-notation is not monads, rather it is syntactic sugar to make the use of monads bearable. Something like lisp macros would be a more general solution to the same problem.
- mightybyte 12y agoBut lisp macros don't give you the strong type safety properties that Haskell gives you with monads. The most general solution is not always the thing you want. Sometimes you want the solution that gives you the strongest guarantees about the potential behavior of code.
- olavk 12y agoMy point is that do-notation is comparable to macros since it is a kind of syntactic sugar. Monads on the other hand are a type (or design pattern, depending on perspective), not a kind of syntactic sugar. So you can't compare lisp macros to monads.