[GHC] #10982: Warn about unused pattern variables in type families

GHC ghc-devs at haskell.org
Mon Dec 7 13:09:53 UTC 2015


#10982: Warn about unused pattern variables in type families
-------------------------------------+-------------------------------------
        Reporter:  jstolarek         |                Owner:  msosn
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  7.11
      Resolution:                    |             Keywords:  newcomer
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D1576
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 This is a bit fiddly.  Here are some facts about the current
 implementation:

 * Named wildcards are part of the abstract syntax of types; see the
 `HsWildCardTy` constructor of `HsType` and the data type
 `HsTypes.WildCardInfo`.

 * If `-XNamedWildCards` is on, we make a `NamedWildCard` for any `_v` in a
 type; see `Parser.y` and the call to `mkNamedWildCardTy`.  That puts a
 `NamedWildCard` in many places that it does not "belong", which is what
 gives rise to the fallout in comment:2

 The Right Thing is probably not to put `HsWildCardTy` into types where
 they aren't allowed.   Really they should only show up in `LHsSigWcType`.
 So I suppose that one simple thing would be to parse wildcards as
 `HsTyVar`, and then either

 * Make `mkLHsSigWcType` traverse the type and replace appropriate
 `HsTyVars` with `HsWildCardTy`, or

 * Make the renamer do this job.

 Probably the latter is best.

 Simon

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10982#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list