News for hackers. Stuff that matters.
Re:Confession of a Haskell Hacker by DanWaterworth on Sunday July 08, 2012 @11:16AM (#4214741)
I think the interesting point here is that Haskell provides such a high static assurance out of the box that what you write is correct that this can happen. You'd never hear of a ruby programmer releasing a gem without trying it.
Re:Confession of a Haskell Hacker by calpaterson on Sunday July 08, 2012 @11:22AM (#4214763)
With the serious caveat that the program you are writing must only be vulnerable to the kind of errors which Hindley-Milner can show aren't present. ie: no IO, no non-deterministic concurrency, no non-total functions, etc, etc.
Re:Confession of a Haskell Hacker by dwc on Sunday July 08, 2012 @01:35PM (#4215068)
I wish this caveat were attached every time someone mentioned the "once it compiled it worked first time" bit. Not because there's no truth in the works-if-compiles idea, but because getting smug about it is sure to bite you in the ass sooner rather than later.

Now that I've said that, I'll state what should be obvious (and probably is to many/most): failure to compile due to type errors is a big clue I am thinking about something incorrectly or incompletely. It's not like I just twiddle stuff until it compiles. I look at it and say, "Duh! That was dumb of me!" It's like using Unit Analysis working out a long physics problem... errors in your thinking about it are very likely to show up in unit analysis. The chance of you coming up with a bogus equation that passes unit analysis is pretty small. When it doesn't pass, you have a good look and find where you went wrong rather than merely tweak.

Re:Confession of a Haskell Hacker by scarmig on Sunday July 08, 2012 @04:49PM (#4215658)
That little connection sent me on a Google quest.

Interesting paper along those lines:

"Types for Units of Measure: Theory and Practice": http://research.microsoft.com/en-us/um/people/akenn/units/CE...

Re:Confession of a Haskell Hacker by dwc on Sunday July 08, 2012 @05:22PM (#4215772)
Oh! I am so glad you looked that up. Thank you!
Re:Confession of a Haskell Hacker by jeffdavis on Sunday July 08, 2012 @12:21PM (#4214902)
You forgot the bug: "doesn't do what you want, but does it perfectly".
Re:Confession of a Haskell Hacker by danieldk on Sunday July 08, 2012 @12:14PM (#4214889)
In addition to that, it's often difficult to predict the runtime properties of a Haskell program. Due to it's laziness, one can often run into space leaks where thunks are not evaluated (yet):

http://blog.ezyang.com/2011/05/space-leak-zoo/

Re:Confession of a Haskell Hacker by viscanti on Sunday July 08, 2012 @01:54PM (#4215119)
That's still a significant portion of the code-base though. In almost every other language you'd have to write tests to accomplish the same thing. It's certainly possible to compose functions that return something of the correct type but not the correct value (in fact, that's trivial to do). Those should be easier to spot/debug/test than the errors the type system checks for you.
Re:Confession of a Haskell Hacker by dododo on Sunday July 08, 2012 @11:29AM (#4214784)
it's a matter of how much you put into the type system:

  add :: Integer -> Integer -> Integer
  add x y = x * y
in any moderately complicated code, you need to test. types only go so far.
Re:Confession of a Haskell Hacker by sold on Sunday July 08, 2012 @01:14PM (#4215015)
To supplement "it's a matter of how much you put into the type system":

This error can be caught if you put units of measure into type system. F# can do this, and addition function will have type int<a> -> int<a> -> int<a> while multiplication int<a> -> int<b> -> int<a * b>; for example, int<m/s> -> int<s> -> int<m> might be a function taking velocity and time, and returing distance. I think Haskell has libraries for this.

Similarily, add x y = x - y would be detected if (-) required a group, while (+) worked for monoids only.

However, it would be rather hard to create a type system detecting a typo in:

quadruple x = 3 * x

Re:Confession of a Haskell Hacker by JadeNB on Sunday July 08, 2012 @02:14PM (#4215174)
> it's a matter of how much you put into the type system:

It's also a matter of how much polymorphism you have. There are lots of functions `Integer -> Integer`; there is only one total function `a -> a`. (This is the parametricity theorem mentioned by sanxiyn in http://news.ycombinator.com/item?id=4215055 .)

Re:Confession of a Haskell Hacker by cwzwarich on Monday July 09, 2012 @02:31AM (#4216949)
There are lots of different functions `a -> a`. One could take a few cycles to complete, whereas others could take a day or week to complete. One could use a few bytes of space, whereas others could use megabytes or gigabytes.
Re:Confession of a Haskell Hacker by JadeNB on Monday July 09, 2012 @11:27AM (#4218617)
I think that this is a different meaning of 'different' from the one usually recognised in computer science; it's my understanding that what usually matters is extensional equality (are the same outputs (eventually) produced for the same inputs?) rather than intensional equality (are those outputs produced in the same way?). Otherwise, all compiler transformations would be illegal.

(You could argue that a (correct) transformation that sends space usage way up may actually change even extension equality, in the sense that it could result in the transformed algorithm failing on a given piece of hardware when the original algorithm would have succeeded. However, my understanding is that the state of 'realistic' computer science, where hardware limitations are part of the reasoning, is in a much more primitive state than 'idealised' computer science.)

Re:Confession of a Haskell Hacker by Peaker on Sunday July 08, 2012 @11:35AM (#4214799)
Opaque types like "Integer" don't give a lot of assurance, so either you get a stronger type system (Agda-style) or you have to test.

But complicated code may work with non-opaque types, and so it could still be reliable without tests.