[GHC] #11451: Inconsistent warnings for unused binders
GHC
ghc-devs at haskell.org
Tue Jan 19 22:32:26 UTC 2016
#11451: Inconsistent warnings for unused binders
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
All that you say is true about type function too. In
{{{
type instance F a a = Int
}}}
the `a` is definitely not unused becuase it is repeated. In both your
examples the type variables patently are used, and no one is suggesting
they are reported as unused:
{{{
instance C a a where ...
instance D a b => C (a,b) where...
}}}
But it really does seem useful an convenient to be able to write
{{{
type instance F (Maybe _) = Int
}}}
to stress that the argument to `Maybe` plays no further role in matching
or on the RHS. Isn't it?
Similarly would it not be reasonable to allow
{{{
instance C (Maybe _) where ...
}}}
to stress that the argument type of the `Maybe` plays no further role in
resolving this class instance.
So let me be more concrete. Here's a proposal:
* If a type variable (a) is bound in a type pattern (b) appears at exactly
once anywhere in its scope, then it is reported as unused.
* A "type pattern" is
* a type on the LHS of a `type instance` or
* a type in the head of a class `instance` (i.e. the bit after the `=>`)
* a type in a pattern type signature e.g. `case x of Just (x :: (a,b))
-> blah`
Now, can you give me an example where that would be annoying? Mabye you
are right, but let's see.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11451#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list