Skip to content

Warn about unused parameters in recursive definitions

I’m correcting student’s exams right now; a good source of bad programs :-)

Consider this program:

foo _ y [] = y
foo z y (_:xs) = foo z y xs

It would be nice if GHC would warn that the first parameter of foo is not used. IIRC GHC warns about unused constructors even when they occur on RHSs.

If foo is passed to some higher order function that expects a particular type, removing the parameter would require a wrapper for there, or at least an anonymous lambda... but it’s probably still worth notifying the programmer, as more likely there is a bug or misunderstanding in such code.

Trac metadata
Trac field Value
Version 7.8.2
Type FeatureRequest
TypeOfFailure OtherFailure
Priority low
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information