Hacker News new | ask | show | jobs
by thinkpad20 4607 days ago
Haskell is really not much more strongly typed than Java, or even C++ (although it's much less liberal with letting you cast than either of those languages). Just like those languages, if a function has been declared to use types a, b and c, then you'd better supply types a, b, and c as arguments. This is the same. The only real extension that I can see is the ability to create functions which accept or return arbitrary types, like `foo :: a -> [a]`, which isn't an option in Java or C++ without some hackery. Of course there are type classes and algebraic data types and other things as well, but I don't think they really make the language "more strongly typed," just more expressive in their types.

What makes Haskell a little challenging in the beginning is its currying, which means you don't need to call a function with all of its stated arguments, and the fact that function application associates to the left; i.e. that `f x y` is the same as `(f x) y`, NOT `f (x y)`, which is closer to how it would be in, say, Ruby or CoffeeScript. There are very good reasons for this, but it does take some getting used to. Currying and associativity rules are responsible for a lot of seemingly incomprehensible type errors. You get better at avoiding them as time goes on. I feel that the weirdness of reading Haskell DSLs, like Parsec, which often make heavy use of customized operators, or do-notation, is an extension of these issues, since most of the difficulty comes from trying to figure out how the types propagate through what amounts to be long, complicated chains of function applications.