Dealing with GHC 7.10 prelude imports

Hi, I've run into a couple of cases when attempting to support multiple GHC versions in my libraries (7.6.3 -> 7.10) where I've repeatedly made mistakes due to being warned about unused imports for various modules that are now part of the Prelude such as Data.Monoid, Data.Foldable, etc. which I subsequently remove either manually or via editor automation sufficiently indistinguishable from magic. This then results in successful compilation on 7.10 and failure on earlier versions of GHC due to missing imports (ie. Data.Monoid (mappend, mempty)), which prior to my current workflow of manually building on multiple versions of GHC before releasing a new version, manifested once or twice only after uploading to Hackage. Now this is all user/workflow error on my part, but I wondered if others have some kind of trick up their sleeve for avoiding these kind of issues? I could attempt to tailor the compiler's warning flags appropriately, but it bodes ill for spotting genuinely unused imports. Cheers, Brendan

See https://ghc.haskell.org/trac/ghc/wiki/Migration/7.10.
I have just solved one of these by doing
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ < 709
import Data.Monoid hiding ((<>))
#endif
Alan
On Sun, Apr 12, 2015 at 9:55 AM, Brendan Hay
Hi,
I've run into a couple of cases when attempting to support multiple GHC versions in my libraries (7.6.3 -> 7.10) where I've repeatedly made mistakes due to being warned about unused imports for various modules that are now part of the Prelude such as Data.Monoid, Data.Foldable, etc. which I subsequently remove either manually or via editor automation sufficiently indistinguishable from magic.
This then results in successful compilation on 7.10 and failure on earlier versions of GHC due to missing imports (ie. Data.Monoid (mappend, mempty)), which prior to my current workflow of manually building on multiple versions of GHC before releasing a new version, manifested once or twice only after uploading to Hackage.
Now this is all user/workflow error on my part, but I wondered if others have some kind of trick up their sleeve for avoiding these kind of issues? I could attempt to tailor the compiler's warning flags appropriately, but it bodes ill for spotting genuinely unused imports.
Cheers, Brendan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

You can use a custom Prelude. E.g., the "base-prelude" project takes care
of this problem: http://hackage.haskell.org/package/base-prelude
2015-04-12 11:14 GMT+03:00 Alan & Kim Zimmerman
See https://ghc.haskell.org/trac/ghc/wiki/Migration/7.10.
I have just solved one of these by doing
{-# LANGUAGE CPP #-} #if __GLASGOW_HASKELL__ < 709 import Data.Monoid hiding ((<>)) #endif
Alan
On Sun, Apr 12, 2015 at 9:55 AM, Brendan Hay
wrote: Hi,
I've run into a couple of cases when attempting to support multiple GHC versions in my libraries (7.6.3 -> 7.10) where I've repeatedly made mistakes due to being warned about unused imports for various modules that are now part of the Prelude such as Data.Monoid, Data.Foldable, etc. which I subsequently remove either manually or via editor automation sufficiently indistinguishable from magic.
This then results in successful compilation on 7.10 and failure on earlier versions of GHC due to missing imports (ie. Data.Monoid (mappend, mempty)), which prior to my current workflow of manually building on multiple versions of GHC before releasing a new version, manifested once or twice only after uploading to Hackage.
Now this is all user/workflow error on my part, but I wondered if others have some kind of trick up their sleeve for avoiding these kind of issues? I could attempt to tailor the compiler's warning flags appropriately, but it bodes ill for spotting genuinely unused imports.
Cheers, Brendan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

I've run into a couple of cases when attempting to support multiple GHC versions in my libraries (7.6.3 -> 7.10) where I've repeatedly made mistakes due to being warned about unused imports for various modules that are now part of the Prelude such as Data.Monoid, Data.Foldable, etc. which I subsequently remove either manually or via editor automation sufficiently indistinguishable from magic.
A trick is to import Prelude at the very end, like: import Control.Applicative import Data.Monoid ... import Prelude Since the unused import check is done from top to bottom, and you almost always use *something* from the Prelude, this will suppress the warning. There are some problems with qualified/explicit import lists if I recall correctly though. But it works for me most of the time. Regards, Benno

Thanks for the tips!
On 12 April 2015 at 12:37, Benno Fünfstück
I've run into a couple of cases when attempting to support multiple GHC versions in my libraries (7.6.3 -> 7.10) where I've repeatedly made mistakes due to being warned about unused imports for various modules that are now part of the Prelude such as Data.Monoid, Data.Foldable, etc. which I subsequently remove either manually or via editor automation sufficiently indistinguishable from magic.
A trick is to import Prelude at the very end, like:
import Control.Applicative import Data.Monoid ... import Prelude
Since the unused import check is done from top to bottom, and you almost always use *something* from the Prelude, this will suppress the warning.
There are some problems with qualified/explicit import lists if I recall correctly though. But it works for me most of the time.
Regards, Benno
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Hi,
the only problem with the "import Prelude" trick is that it does not help
when you explicitly list what you import. For example, in one of my files I
had:
import Control.Applicative ((<$>))
which will still result in a warning. Simply change it to
import Control.Applicative
import Prelude
However, sometimes there are conflicting names due to reexports. For
example, forM is both in Data.Traversable and Control.Monad. In such a
case, use "hiding" for one of them.
Also change
import <module> (<f>)
to
import <module> hiding (<everything except f>)
if you want to avoid CPP at all cost.
I too went through a few cycles 7.8.4 <-> 7.10.1 trying to make the code
warning free on both (I don't use Travis but having minghc on Windows or
using HVR's PPA on Ubuntu helps a lot).
Michal
On Sun, Apr 12, 2015 at 3:45 PM, Brendan Hay
Thanks for the tips!
On 12 April 2015 at 12:37, Benno Fünfstück
wrote: I've run into a couple of cases when attempting to support multiple GHC versions in my libraries (7.6.3 -> 7.10) where I've repeatedly made mistakes due to being warned about unused imports for various modules that are now part of the Prelude such as Data.Monoid, Data.Foldable, etc. which I subsequently remove either manually or via editor automation sufficiently indistinguishable from magic.
A trick is to import Prelude at the very end, like:
import Control.Applicative import Data.Monoid ... import Prelude
Since the unused import check is done from top to bottom, and you almost always use *something* from the Prelude, this will suppress the warning.
There are some problems with qualified/explicit import lists if I recall correctly though. But it works for me most of the time.
Regards, Benno
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
participants (5)
-
Alan & Kim Zimmerman
-
Benno Fünfstück
-
Brendan Hay
-
Michal Antkiewicz
-
Nikita Volkov