Warnings about unused variables or imports

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Tue May 6 05:31:15 EDT 2008


On Tue, 2008-05-06 at 10:09 +0100, Simon Peyton-Jones wrote:

> There is something more substantial here.  Suppose we have
> 
>     module Foo( g ) where
>         import Bar( f4 )
>         f1 = f2
>         f2 = f3
>         f3 = f4
>         g = 7
> 
> At the moment GHC takes the view that f1,f2,f3,f4, and the import are
> *all* unused.  If we said that just f1 was unused, then you'd delete
> it and get a new warning about f2; you delete that and get a new
> warning about f3; and so on.
> 
> Yet the current behaviour is clearly confusing, even to a clued-up
> user, let alone a beginner.

Perhaps to eliminate the confusion we just need to distinguish directly
unused and indirectly unused in the warning message:

Foo.hs:3:8: Warning: Defined but not used: `f1'
Foo.hs:4:8: Warning: Defined but used only by other things that are
                     themselves unused: `f2'
Foo.hs:5:8: Warning: Defined but used only by other things that are
                     themselves unused: `f3'

(suggestions for better messages text welcome)

and similarly for the unused import.

Duncan



More information about the Glasgow-haskell-users mailing list