Unused import warning on re-export

Simon Peyton Jones simonpj at microsoft.com
Thu May 11 20:23:00 UTC 2017


| Is there a reason GHC considers this case an unused import? It seems that
| the use of the import is explicitly stated right within the import
| itself. Should I submit a ticket for this?

Hmm.  I think you are saying that

  module A where
    import B as A(f)
    g = True

that is equivalent to
   module A( module A ) where ...

which exports all things "x" in scope as "A.x".  So it'll export both f and g.

But GHC will report f as unused, but not g. And that's inconsistent.  Fair point.  Yes, file a ticket.  Better still, offer a patch :-).

Simon

| -----Original Message-----
| From: Glasgow-haskell-users [mailto:glasgow-haskell-users-
| bounces at haskell.org] On Behalf Of Yitzchak Gale
| Sent: 10 May 2017 13:56
| To: GHC users <glasgow-haskell-users at haskell.org>
| Subject: Unused import warning on re-export
| 
| I have a module A with no export list, and a function f which from the
| API point of view should part of the export list of A. But f must be
| defined in module B, not module A, due an import cycle. I added this line
| in module A to re-export f from A:
| 
| import B as A (f)
| 
| This resulted in an unused import warning. That is a problem for us - we
| keep our large code base clean of warnings as a policy.
| 
| Is there a reason GHC considers this case an unused import? It seems that
| the use of the import is explicitly stated right within the import
| itself. Should I submit a ticket for this?
| 
| Thanks,
| Yitz
| _______________________________________________
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at haskell.org
| https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmail.hask
| ell.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fglasgow-haskell-
| users&data=02%7C01%7Csimonpj%40microsoft.com%7C81b06c9737d540a597df08d497
| a413d0%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636300178355700119&sd
| ata=xHt1FXEF5r4WMaMF3FSW4jFBRlB4OK8DQdcNAxZ7HOc%3D&reserved=0


More information about the Glasgow-haskell-users mailing list