I would like to know your opinion on declaration by hand of parameters/return types in languages with type inference like Scala. Is there any reason why to or not to do this when compiler can infer types?
I cannot speak for Scala (but I think what I write will apply there, too), but for example Haskell's type system has the property that it infers the most general type, yet this is not always what you want. Consider this simple example:
The type checker infers this type for
which means that if you pass a value of numeric type (
to get a more specific version.
Another point are higher rank types, type inference for higher rank types is undecidable for ranks > 1, hence if you have a higher rank function, you actually need to annotate it. The compiler can then check the type, but it can't infer it. The type system of Frege is similar to that of Haskell 2010 with the addition of higher ranked types, hence the same applies here.