News for hackers. Stuff that matters.
Re:Monads Are Not Metaphors (2010) by olavk on Thursday September 10, 2015 @04:11AM (#10196722)
I don't believe monads are worth the bother without some syntactic sugar. Without sugar, it is just a sequence of operations converted into a chain of nested lambdas with one lambda for each operation. Cool, but far to convoluted to write for any real-world programs.

The attempts to introduce monads in other languages like Python, Ruby etc. is missing what make them a useful tool in Haskell.

Re:Monads Are Not Metaphors (2010) by tikhonj on Thursday September 10, 2015 @12:11PM (#10198876)
I've used Async and LWT in OCaml—libraries for monadic asynchronous programming—and the abstraction can still be useful without syntax sugar.

Hell, JavaScript promises are basically a bastardized and slightly inconsistent monad, and they're still useful even without syntax sugar. If we could generalize over the API and use them for other things it would be even better, but that's not the JavaScript way.

Re:Monads Are Not Metaphors (2010) by olavk on Thursday September 10, 2015 @04:57PM (#10200519)
How are JS promises monads?
Re:Monads Are Not Metaphors (2010) by tikhonj on Thursday September 10, 2015 @06:08PM (#10200868)
They actually operate on more or less the same principle as Async and LWT, similar to Haskell's Cont.

The .then method is bind. Or it would be if they didn't automatically flatten nested promises. Since they do, then is a hybrid of map and bind that doesn't quite cover the use cases for both.

Re:Monads Are Not Metaphors (2010) by exDM69 on Thursday September 10, 2015 @05:49AM (#10197065)
> The attempts to introduce monads in other languages like Python, Ruby etc. is missing what make them a useful tool in Haskell.

While I agree that the syntactic sugar of the "do" notation in Haskell makes Monads vastly more useful, there are examples where Monads have been applied in other programming languages without any syntactic sugar.

For example, there are parser combinator libraries (influenced by Parsec) in many languages. E.g. Python's pyparsec is internally using monads that are defined just as they are in Haskell.

Monads are a great idea for many practical tasks in programming, their use in Haskell is often emphasized becuse they're required for IO (which is not the case for imperative languages). For many of the non-IO applications of monads, they're just as useful in other languages too.