Can GHC or some lint tool tell me when I’ve provided a type signature for a function that could be more polymorphic?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
GHC doesn’t do this, and a quick search of Hackage turns up nothing.
A simple, but possibly quite effective way to implement such a thing would be to load the module in GHCi, use
:browseto get all the type signatures, then load a copy without any type signatures, use:browseagain, and compare the two outputs; then just print all the lines that differ beyond parentheses, whitespace and alpha-renaming. However, this wouldn’t work perfectly, especially if you have definitions whose types can’t be inferred.I have a feeling such a tool would turn up a lot of false positives in practice.