3 ms·
Yeah, then maybe just shorten `fun` to `f` or `fn` like elixir. I think even just one char makes a difference over thousands of LoC.
by devmunchies 4y ago
Yeah, then maybe just shorten `fun` to `f` or `fn` like elixir. I think even just one char makes a difference over thousands of LoC.
- masklinn 4y agoIn haskell (and elm) it's `\` which is quite OK (and also a nod to the lambda symbol λ). But yes "fn" is quite nice (taking over "f" is a bit much). And a few characters can definitely degrade the experience, especially as "u" and "n" are typed with the exact same finger. Anonymous functions were definitely one of my least favorite features in Erlang, not because they don't work well but because their leading keyword is "fun" and there's an arrow between the (parenthesised) parameters and body and they also have a closing keyword "end": map(fun(X) -> 2 * X end, [1,2,3,4,5]). That's a bit much. But HoFs in general are quite awkward, as referring to a named function also requires the `fun` leading keyword, and requires specifying the arity, so map(fun double/1, [1,2,3,4,5]). after having defined the function as double(X) -> 2 * X. (as you can see Erlang would really rather you defined named functions).