<div dir="ltr">I guess for re-exports we could relax the requirement that the symbol comes from only one module. I don't know if that is better though. If I saw<br><div><br></div><div>import Data.Monoid (Monoid)</div><div>import Prelude (Monoid)</div><div><br></div><div>I'd say that code wasn't the pretties, because it would confuse users, who would have to figure out that the two were the same. Re-exports are generally confusing, because they break abstraction by saying that two things are the same and will continue to be so, which isn't always what you want.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 26, 2015 at 6:06 PM, Simon Peyton Jones <span dir="ltr"><<a href="mailto:simonpj@microsoft.com" target="_blank">simonpj@microsoft.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">OK. I've created a ticket<br>
<a href="https://ghc.haskell.org/trac/ghc/ticket/10117" target="_blank">https://ghc.haskell.org/trac/ghc/ticket/10117</a><br>
<br>
In fact there is a pretty good specification here<br>
<a href="https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/UnusedImports" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/UnusedImports</a><br>
<br>
So back to you: based on the existing, can you think of a variant that would work better?<br>
<span class="im HOEnZb"><br>
Simon<br>
<br>
| -----Original Message-----<br>
| From: Herbert Valerio Riedel [mailto:<a href="mailto:hvriedel@gmail.com">hvriedel@gmail.com</a>]<br>
</span><span class="im HOEnZb">| Sent: 24 February 2015 12:00<br>
| To: Simon Peyton Jones<br>
| Cc: Herbert Valerio Riedel; Johan Tibell; Edward Kmett; Austin Seipp<br>
| Subject: Re: The suggested redundant import solution doesn't work for<br>
| explicit import lists<br>
|<br>
</span><div class="HOEnZb"><div class="h5">| Simon,<br>
|<br>
| The problem:<br>
|<br>
| trying to avoid redundant-import warnings due symbols having moved to<br>
| 'Prelude' due to AMP/FTP w/o CPP usage<br>
|<br>
| e.g.<br>
|<br>
| import Control.Applicative (Applicative)<br>
|<br>
| foo :: Applicative f => ...<br>
| foo = ...<br>
|<br>
| now warns that 'Applicative' is redundant, as it's exported from<br>
| 'Prelude' now. 'Monoid' is another such example that's now re-exported<br>
| from 'Prelude' (but wasn't before GHC 7.10).<br>
|<br>
|<br>
| One thing that happens to work is the trick shown at<br>
| <a href="https://ghc.haskell.org/trac/ghc/wiki/Migration/7.10#GHCsaysTheimporto" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/Migration/7.10#GHCsaysTheimporto</a><br>
| f...isredundant<br>
| i.e.<br>
|<br>
| module Foo (Int, Word, Monoid(..)) where<br>
|<br>
| import Data.Monoid<br>
| import Data.Word<br>
| import Prelude<br>
|<br>
| as in that case, 'Prelude' is explicitly imported last, and so GHC<br>
| doesn't warn about Data.{Word,Monoid} being redundant (due to the way<br>
| the redundancy-check is implemented in GHC)<br>
|<br>
| However, if the example above is rewritten as<br>
|<br>
| module Foo (Int, Word, Monoid(..)) where<br>
|<br>
| import Data.Monoid (Monoid(..))<br>
| import Data.Word (Word)<br>
| import Prelude<br>
|<br>
| GHC would warn, as it handles import-listed symbols differently than<br>
| wildcard imports...<br>
|<br>
| and the question is, whether we can easily get the latter example to<br>
| become warning free as well w/o risking breakages elsewhere...<br>
|<br>
| ...is it clearer now what I'm suggesting?<br>
|<br>
| Cheers,<br>
| hvr<br>
|<br>
| On 2015-02-24 at 12:50:35 +0100, Simon Peyton Jones wrote:<br>
| > I'm sorry, but can someone re-articulate the question? I'm deep<br>
| underwater, so reluctant to reverse-engineer the question from the<br>
| thread.<br>
| > I think you are asking for some feature. But I'm not sure what the<br>
| spec is.<br>
| ><br>
| > Simon<br>
| ><br>
| > | -----Original Message-----<br>
| > | From: Herbert Valerio Riedel [mailto:<a href="mailto:hvriedel@gmail.com">hvriedel@gmail.com</a>]<br>
| > | Sent: 24 February 2015 11:29<br>
| > | To: Johan Tibell<br>
| > | Cc: Edward Kmett; Simon Peyton Jones; Austin Seipp<br>
| > | Subject: Re: The suggested redundant import solution doesn't work<br>
| > | for explicit import lists<br>
| > |<br>
| > | Johan,<br>
| > |<br>
| > | You're right, I'm afraid the Prelude-trick doesn't work well with<br>
| > | import-lists... not sure though if it's worth the risk to tweak<br>
| GHC<br>
| > | 7.10.1's redundant-warning detection to make it work here too...<br>
| > |<br>
| > | @SPJ, any comments?<br>
| > |<br>
| > | for more context:<br>
| > |<br>
| > | -<br>
| > |<br>
| <a href="https://ghc.haskell.org/trac/ghc/wiki/Migration/7.10#GHCsaysTheimporto" target="_blank">https://ghc.haskell.org/trac/ghc/wiki/Migration/7.10#GHCsaysTheimporto</a><br>
| f..<br>
| > | .isredundant<br>
| > | -<br>
| > |<br>
| <a href="http://www.reddit.com/r/haskell/comments/2wx64g/ghc_710_will_use_pla" target="_blank">http://www.reddit.com/r/haskell/comments/2wx64g/ghc_710_will_use_pla</a><br>
| > | n_ftp<br>
| > | /covdas0<br>
| > |<br>
| > | Cheers,<br>
| > | hvr<br>
| > |<br>
| > | On 2015-02-24 at 11:47:30 +0100, Johan Tibell wrote:<br>
| > | > The suggested fix for unused imports resulting from the move of<br>
| e.g.<br>
| > | > Data.Monoid doesn't work when using explicit import lists:<br>
| > | ><br>
| > | > $ cat Test.hs<br>
| > | > module Test where<br>
| > | ><br>
| > | > import Data.Monoid (Monoid)<br>
| > | > import Prelude<br>
| > | ><br>
| > | > f :: Monoid a => a<br>
| > | > f = undefined<br>
| > | > $ ghc-7.10.0.20150123 -Wall /tmp/Test.hs<br>
| > | > [1 of 1] Compiling Test ( /tmp/Test.hs, /tmp/Test.o<br>
| )<br>
| > | ><br>
| > | > /tmp/Test.hs:3:1: Warning:<br>
| > | > The import of ‘Data.Monoid’ is redundant<br>
| > | > except perhaps to import instances from ‘Data.Monoid’<br>
| > | > To import instances alone, use: import Data.Monoid()<br>
| > | ><br>
| > | > It does work if you don't have an import list (bad idea) or use<br>
| > | qualified<br>
| > | > imports (good idea).<br>
| > | ><br>
| > | > -- Johan<br>
| > |<br>
| > | --<br>
| > | "Elegance is not optional" -- Richard O'Keefe<br>
|<br>
| --<br>
| "Elegance is not optional" -- Richard O'Keefe<br>
</div></div></blockquote></div><br></div>