by elsurudo · 6y ago · 0 comments
Only other use case I can think of is doing metaprogramming or some sort of templating where you have a variable, but might no even know what it represents, because it isn't your concern.
map :: (a -> b) -> [a] -> [b]
map f [] = []
map f (a:as) = f a : map f as
Personally I don't see any reason to use longer names than f, a, and as because you can't add any additional information.You might say "well I don't write code like that", and I don't have any answer for you. But I find I write a fair amount of generic code.
Well you could...
map transforming_function (element:rest_of_list) = transforming_function element : map transforming_function rest_of_list
...but the cost in terms of loss of brevity would far outweigh a benefit that would only accrue to complete beginners, who would be better served by comments and test cases.Because you are writing abstract code.
Odds are that a lot of your code is better done abstract, and only fully specified in a short context.