2 ms·
The point is that Haskell's do notation works for every monad, whereas "product" in Ruby works for just a cartesian product of sets, and not any other use of mo
by Tainnor 3y ago
The point is that Haskell's do notation works for every monad, whereas "product" in Ruby works for just a cartesian product of sets, and not any other use of monads (e.g. generating random values, async code, operations that might return errors, IO operations, and so on).
- asplake 3y agoTo me the ‘product’ in the Ruby example above is helpfully explicit and could be changed for something else.
- regularfry 3y agoThe 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.
- Tainnor 3y ago> 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.
- twic 3y ago"Haskell is best at solving problems that Haskell invented and other languages do not have." -- Jon Harrop