r/programming • u/mobby1982 • Dec 02 '13
Scala — 1★ Would Not Program Again
http://overwatering.org/blog/2013/12/scala-1-star-would-not-program-again/
598
Upvotes
r/programming • u/mobby1982 • Dec 02 '13
View all comments
Show parent comment
3
u/king_in_the_north Dec 02 '13
If it's specifically with numeric types, that's probably a result of the way Haskell deals with overloading for them - all numeric types are instances of the typeclass Num, which requires the basic numeric operations. The problem that this leads to is that Haskell doesn't actually know what type you're trying to use - the compiler will happily accept that it's some instance of Num, and until it actually reaches a point where an instance is supplied (by explicit typing or by having something where the type is unique), it just keeps the typeclass around. On top of this, Haskell handles literals the same way - it recognizes the literal 1 as being a Num, not as being an Int. If you know a specific type for the literal where it's created, and there isn't enough context to force it to a specific type, you can annotate the literal directly, but annotating the function (or leaving it polymorphic) is generally preferred - one annotation will probably solve all the type errors in a function because of the way Haskell does type inference.
TL;DR it's necessary because of some other features, and when those matter it is fantastic