Re:Haskell and the "foul stench of cargo cult mathematics"
by xyzzyz on Monday December 27, 2010 @02:30PM
(#2043384)
He knows, as it is clearly visible in his article. His point is, he should not need to.
Re:Haskell and the "foul stench of cargo cult mathematics"
by hesselink on Monday December 27, 2010 @03:43PM
(#2043600)
Actually, you don't need to in most real programs. You usually use the elements of a list with some function that makes it clear what type they have.
In GHCi (the interpreter) this doesn't happen. It has some defaulting rules to alleviate this, but I don't quite understand them, so I can't say why they didn't kick in in this case.
Re:Haskell and the "foul stench of cargo cult mathematics"
by rtperson on Monday December 27, 2010 @05:13PM
(#2043815)
The thing with Haskell is that it doesn't automatically coerce types the way other languages do. It uses Hindley-Milner type inference up front if you don't specify your types, but this is far from foolproof. Once it's decided you're using type Foo, you're stuck. You need explicit typing in many cases.
One of the first things you learn as a Haskell programmer is to treat type inference with suspicion.
Re:Haskell and the "foul stench of cargo cult mathematics"
by jwatzman on Monday December 27, 2010 @05:49PM
(#2043904)
Languages like SML and OCaml also use this sort of type inference, but you tend to not need type annotations in those languages except in very special cases. I think this is also fairly true of Haskell -- type inference works in 99% of the cases, and explicit type annotations are just a stylistic thing.
Re:Haskell and the "foul stench of cargo cult mathematics"
by rtperson on Monday December 27, 2010 @09:33PM
(#2044391)
Most of the time you're right. But I've done a fair bit of tinkering with Haskell's OpenGL library. Trying to get GHC to differentiate between a Float and a GLfloat inside a Vector is pretty much impossible without resorting to explicit typing. This definitely qualifies as a special case, but it's cropped up often enough as to make me a little gun shy. You don't need to explicitly type everything, just enough to give the compiler a credible hint as to what you're trying to do -- such as the last term in your vector.
The sad thing about the original article is that the writer is throwing his hands up and raging over what is really a small implementation hiccup. I kind of like that the compiler withholds judgment on whether '5' is a Float, Int, or Integer. It means that I no longer need to type ".0" after every Float.
Re:Haskell and the "foul stench of cargo cult mathematics"
by alnayyir on Monday December 27, 2010 @02:47PM
(#2043432)
This is a property of many statically typed languages, and Haskell isn't known for being one of the more forgiving languages in that family.
I appreciate that his goals were more mathematically oriented than not, but surely he would've seen something like this coming?
[1,2,3,4,5] :: [Int] problem solved!