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

Monads are important, but I don't think it's fair to call them the "crux" of Haskell programming. For some reason, monads are over-dramatized and get far more attention than other great Haskell features and abstractions, possibly making Haskell's already unfair reputation as difficult and academic even worse.


Monads are important, but I don't think it's fair to call them the "crux" of Haskell programming

That may be overstating things a little, I agree. On the other hand, a programming language that can't model ordering of events along some sort of timeline isn't useful for many practical applications, and monads have so far proven to be the most effective way of introducing those concepts into Haskell's naturally timeless environment. They're also absurdly overcomplicated for modelling simple but not trivial cases, relative to just writing the code in the order you want things to happen in an imperative language. So if the goal is to get more people to use Haskell to write useful software, I would expect a lot of emphasis on monads and related concepts.


> 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).


But you end up having to use monads if you want to do IO or interact with many popular packages, so being able to use monads well ends up being an essential skill for getting anything done at all.




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

Search: