Is there method - based on, e.g. analysis of recursive structure or other static analysis - to identify functions that could be made parametrically polymorphic?
For instance, if I had mistakenly written
reverse :: [Int] -> [Int]
reverse [] = []
reverse (x:xs) = reverse xs ++ [x]
this optimization would correct the type signature to
reverse :: [a] -> [a]
My guess is that this sort thing is fairly standard, but I haven't found the right thing to Google. Can someone pass on a reference?