Another bikeshed thought.
Having these parens be optional makes an opening for
Did you mean to annotate the parameter type or the return type?
but gives so little back.
If we’re into character optimizing how about we rename mapWithDefault
[edit: to say more I am trying to train a team of less experienced engineers and, as you may guess, they are very easily thrown by error messages, so I am really starting to appreciate the effort Elm made, etc]
Got it, thank you. Small nitpick, but the wording of the error message and the examples given are in opposite orders.
EDIT: also, my 2c: not giving explicit type annotations at the implementation level also neatly avoids this issue (and brings other benefits as well). If type annotations are needed, interfaces are the best place to put them imho.
let f: int => int
let f = a => a + 1
I think in general you define functions before applying them, which makes type annotation necessary for things like callbacks, function props in many cases. If I wanted to fix this with idiom Id be writing python
I dont think a language like this should discourage people from annotating any time they feel the need as its valid, and ime is a common method of support for people new to typed systems like this.
I’ve found that if you’re having to add a lot of explicit type annotations then you’re probably trying to do something un-idiomatic. I think it could be stressed more in the docs that annotating types is a code smell and if you can write code without annotations then other humans will be able to more easily understand it.