Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> relative to just writing the code in the order you want things to happen in an imperative language

When you write them in the order you want, you're implicitly chaining them with a primitive chain operator that's built-into the language.

In Haskell, this is exactly what "do" notation does. So in what sense is it "overcomplicated"?

Example, Python:

  def func(x, y, z):
    foo(x())
    otherFunc(lambda : y.hello(z))
Haskell:

  func x y z = do
    foo =<< x
    otherFunc (hello y z)
The syntax is slightly more verbose for chaining actions as arguments (foo), but more concise when passing around first-class actions (hello).


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

Search: