Hacker News new | past | comments | ask | show | jobs | submit login

The point is more specific than that: the claim here against this example is that Haskell's `do` notation uniquely lets you avoid indentation depth. The thing is, none of those other examples cause indentation depth problems in other languages because they don't force you through type system hoops to get useful work done.

Besides, you can (ab)use Enumerator for all sorts of monadic things if needs be and end up with something quite terse. A random number generator is trivial, for instance.

I'm not saying that `do` notation isn't a neat trick, it just tends to be a trick other languages don't need. Its generality is both a blessing and a curse.




> The thing is, none of those other examples cause indentation depth problems in other languages

They do, I've seen it happen before. Callback hell was a thing in JavaScript, before Promises happened (and later async/await). And if you've ever written in a functional programming style in a language that doesn't have a first class abstraction for monadic code, then you might have seen cascades of flatMap and map.

FWIW, do notation is not the only option, Scala has for comprehensions that accomplish the same goal.


"Haskell is best at solving problems that Haskell invented and other languages do not have." -- Jon Harrop




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: