3 ms·
> But type inference in Rust and in Haskell can get pretty wacky, with the type determined by code half a page away. Hence the general guideline (in Haskell at
by Quekid5 7y ago
> But type inference in Rust and in Haskell can get pretty wacky, with the type determined by code half a page away.
Hence the general guideline (in Haskell at least) that all top-level definitions should have a type ascription. You can also add ascriptions locally if you have a large function that you think would benefit (readability-wise) from it.
- FreeFull 7y agoIn Rust you are forced to specify the type for functions and consts/statics, there isn't any option for inference there.
- Quekid5 7y agoIndeed. It's a smilar thing in Scala, and I actually find it kind of limiting because Scala (like Rust, AFAIK) doesn't have "where expressions" or "declare a function without types just because", so you're actually discouraged from making really local functions that just frobnicate-the-transmogrifier because every non-anonymous function requires a declaration. (I still very much appreciate Scala for what it is. No real experience outside of toys with Rust.)