|
|
|
|
|
by adimitrov
2618 days ago
|
|
The way to reduce clutter in strongly, statically typed languages is to use strong, robust type inference. For example, Java is pretty terrible at type inference (still) and you have to annotate types almost everywhere (Java 8 had a very tepid improvement on that front.) But languages like Haskell and Rust are very good at type inference, and you almost never actually need to specify the types. It's still good Haskell style to always annotate the type sigs of top-level functions. Why? Because they serve as more than just hints to the compiler: they are part (and a very important part!) of the documentation. That is why they're in-line. Because A function like zipWith:: [a] -> [b] -> (a -> b -> c) -> [c]
tells you what it does in its type signature. |
|
Java 10 and 11 introduced real type inference, at least for local variables and function parameters.