ndmitchell / cmdargs

Haskell library for command line argument processing
Other
91 stars 12 forks source link

Fix the GHC 8.2 build #43

Closed RyanGlScott closed 7 years ago

RyanGlScott commented 7 years ago

The Data.Typeable.Internal module was removed in base-4.10/GHC 8.2. Luckily, cmdargs only imports it for access to tyConName, a function which has been a part of the public Data.Typeable interface for a while, so this can be fixed with some minimal CPP.

RyanGlScott commented 7 years ago

Oh dear, those Travis errors are interesting. I suppose it's because travis.hs is invoking GHC directly on the source files, and older GHCs aren't aware of the MIN_VERSION_base. One way you could fix it is with this change to travis.hs:

diff --git a/travis.hs b/travis.hs
index 2b2bd73..a73a9b0 100644
--- a/travis.hs
+++ b/travis.hs
@@ -2,4 +2,4 @@
 import System.Process.Extra

 main = do
-    system_ "runhaskell Main --test"
+    system_ "runhaskell --ghc-arg=-optP-include --ghc-arg=-optPdist/build/autogen/cabal_macros.h Main.hs --test"

Of course, this assumes that you always run travis.hs after a build, and moreover, that you built it with cabal-install specifically. Would this work for you, @ndmitchell?

ndmitchell commented 7 years ago

Thanks for the patch! The #ifdef was only required for GHC 7.2, so I just ended support for that (I had stopped testing it some time ago, so whether it still worked is somewhat academic).

FWIW, where CPP is required, I always try and make sure the code compiles with GHC alone, not relying on cabal. For base, you can always just #ifdef on the GHC version instead. For other packages, some #ifndef branch defaulting to the latest available works.

ndmitchell commented 7 years ago

I also released cmdargs-0.10.15 with this change.