Quantcast

Unused import warning on re-export

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Unused import warning on re-export

Yitzchak Gale
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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Unused import warning on re-export

Haskell - Glasgow-haskell-users mailing list
| 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-
| [hidden email]] On Behalf Of Yitzchak Gale
| Sent: 10 May 2017 13:56
| To: GHC users <[hidden email]>
| 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
| [hidden email]
| 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
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unused import warning on re-export

Iavor Diatchki
Hello,

actually, the bug here is that `f` is exported, as omitting the export list is not equivalent to writing `module A` in the export list.

This is explicitly stated in Section 5.2 of the Haskell report:

 "If the export list is omitted, all values, types and classes defined in the module are exported, but not those that are imported."

-Iavor









On Thu, May 11, 2017 at 1:23 PM, Simon Peyton Jones via Glasgow-haskell-users <[hidden email]> wrote:
| 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:[hidden email]
| [hidden email]] On Behalf Of Yitzchak Gale
| Sent: 10 May 2017 13:56
| To: GHC users <[hidden email]>
| 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
| [hidden email]
| 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
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users


_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Unused import warning on re-export

Iavor Diatchki
Actually, I just tried to make an example of this, and GHC does not seem to export `f`, just as the report says.  So I'd say GHC is behaving correctly, both with the exports and the warning.



On Fri, May 12, 2017 at 10:39 AM, Iavor Diatchki <[hidden email]> wrote:
Hello,

actually, the bug here is that `f` is exported, as omitting the export list is not equivalent to writing `module A` in the export list.

This is explicitly stated in Section 5.2 of the Haskell report:

 "If the export list is omitted, all values, types and classes defined in the module are exported, but not those that are imported."

-Iavor









On Thu, May 11, 2017 at 1:23 PM, Simon Peyton Jones via Glasgow-haskell-users <[hidden email]> wrote:
| 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:[hidden email]
| [hidden email]] On Behalf Of Yitzchak Gale
| Sent: 10 May 2017 13:56
| To: GHC users <[hidden email]>
| 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
| [hidden email]
| 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
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users



_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Loading...