News for hackers. Stuff that matters.
Re:Ask HN: Why Haskell? by SamReidHughes on Sunday March 30, 2014 @08:34PM (#7498725)
Have you ever used any other statically typed languages? How much of Haskell's benefit do you think it provides that simply having static typing doesn't provide?
Re:Ask HN: Why Haskell? by quchen on Sunday March 30, 2014 @08:47PM (#7498779)
- Haskell types often guide development: the error message ("type mismatch: expected blabla") gives you strong hints about what sort of error you've made. The magnitude of this one is hard to convey by merely writing/reading about it though.

- Easy wrapping to create new types: Ever switched the arguments of `mv` in your terminal (strings)? Read the User ID as an account balance (ints)? You can distinguish these statically, and it's easy to do so. (You can of course write a wrapper class in C++ around Int as well a la "class OtherInt { int value; int get(); set(int i) }", but how often do you do that?

- No IO in a type? It cannot do IO. Has "Monad" in the type? It can do Monadic stuff, but no operations specific to any Monad instance (such as Maybe, IO, ...).

- Types are forced documentation. Don't get me wrong, no documentation is as awful in Haskell as it is anywhere else. However, even without any ordinary comment, a type can give away a lot of what a function does; maybe even more importantly, it tells you what it cannot do. If you see something of type `(a -> b) -> (a -> a)`, you know that the first argument cannot possibly be used - it has to be a dummy parameter.

Re:Ask HN: Why Haskell? by mushly on Monday March 31, 2014 @12:16PM (#7502352)
How do you do documentation in Haskell? For Python and Clojure, there's docstrings. For Java there's Javadoc. For Haskell, there doesn't seem to be any well-established documentation practices.

This is of course not counting the occasional comment explaining why/how you're doing something convoluted.

Re:Ask HN: Why Haskell? by quchen on Monday March 31, 2014 @05:17PM (#7504249)
> For Haskell, there doesn't seem to be any well-established documentation practices.

Oh yes but there is! It's called Haddock. It's widely (and probably exclusively) used. The entirety of the documetation you can find on Hackage [1] (example: [2]) is generated using it. The user guide can be found here [3].

[1]: http://hackage.haskell.org/ [2]: http://hackage.haskell.org/package/pipes-4.1.0/docs/Pipes-Pr... [3]: http://www.haskell.org/haddock/doc/html/

Re:Ask HN: Why Haskell? by dllthomas on Monday March 31, 2014 @05:14PM (#7504234)
There is haddock and literate haskell. Types also serve as some documentation.
Re:Ask HN: Why Haskell? by coolsunglasses on Sunday March 30, 2014 @11:27PM (#7499428)
I have used other statically typed languages (I used to do C# .NET for a living), but Haskell was the first time I felt like I was getting my money's worth so to speak.
Re:Ask HN: Why Haskell? by dllthomas on Sunday March 30, 2014 @08:45PM (#7498771)
When you say "other statically typed languages" do you mean ML and Agda, or Java and C?
Re:Ask HN: Why Haskell? by SamReidHughes on Sunday March 30, 2014 @08:52PM (#7498808)
Any. (Maybe not something as simple C or Go, and nothing like Agda, but something like ML or Java or C++.) There is something wrong with the grandparent post, because it's not making an argument that distinguishes Haskell from other statically typed languages.
Re:Ask HN: Why Haskell? by dllthomas on Sunday March 30, 2014 @09:24PM (#7498942)
Ok, well, for what it's worth I think that Haskell typing is equivalent in strength to ML. It's absolutely stronger than pre-generics Java; possibly isomorphic now. Roughly isomorphic to C++ with templates. In Haskell and ML, inference and clean syntax for type constructors makes it substantially easier to apply that power legibly (and structural pattern matching is a nice bonus). Monads let you extend that power to statements instead of just expressions.
Re:Ask HN: Why Haskell? by ibotty on Monday March 31, 2014 @02:33AM (#7499996)
no, haskell (ghc) has many extensions that extend hindley-milner by a great degree.
Re:Ask HN: Why Haskell? by dllthomas on Monday March 31, 2014 @05:12PM (#7504219)
Yes, I wasn't trying to make any strong claims of theoretical equivalence. In my experience with Haskell and OCaml and much more limited with SML, I've not found myself wanting to express a lot in those languages that I'd have been able to in Haskell, types-wise. Remember that the original question was "How much of Haskell's benefit do you think it provides that simply having static typing doesn't provide?" I should perhaps have been clearer.