Fails to compile with GHC 7.8.3
Hello,
I've investigated a build issue under GHC 7.8.3 when pulling ghc-mod from github. It's a tricky problem.
The compile failure, for context, is:
alejandro@rainbow-generator:~/development/ghc-mod:[master $=]$ git reflog
17dfe6b HEAD@{0}: clone: from https://github.com/cabrera/ghc-mod
alejandro@rainbow-generator:~/development/ghc-mod:[master $=]$ cabal build
Building ghc-mod-4.1.0...
Preprocessing library ghc-mod-4.1.0...
[11 of 33] Compiling Language.Haskell.GhcMod.Gap ( Language/Haskell/GhcMod/Gap.hs, dist/build/Language/Haskell/GhcMod/Gap.o )
Language/Haskell/GhcMod/Gap.hs:283:44:
Constructor ‘MG’ should have 4 arguments, but has been given 3
In the pattern: MG _ in_tys out_typ
In the pattern: FunBind {fun_matches = MG _ in_tys out_typ}
In the pattern: L spn (FunBind {fun_matches = MG _ in_tys out_typ})
So it seems that data MatchGroup changed from GHC 7.8.2 -> GHC 7.8.3. A new field was added to track the MatchGroup origin. Here's the commit showing what changed, where, and when: https://github.com/ghc/ghc/commit/eeaea2df3fa585db503034f419c6e4331a4d8a84#diff-259092edcc59456f526cdef255c181d1L909
Here's a fix to ghc-mod that would break GHC 7.8.[1,2] but fix the build for GHC 7.8.3:
alejandro@rainbow-generator:~/development/ghc-mod:[master *$=]$ git diff
diff --git a/Language/Haskell/GhcMod/Gap.hs b/Language/Haskell/GhcMod/Gap.hs
index 062538b..5ae18ca 100644
--- a/Language/Haskell/GhcMod/Gap.hs
+++ b/Language/Haskell/GhcMod/Gap.hs
@@ -280,7 +280,7 @@ class HasType a where
instance HasType (LHsBind Id) where
#if __GLASGOW_HASKELL__ >= 708
- getType _ (L spn FunBind{fun_matches = MG _ in_tys out_typ}) = return $ Just (spn, typ)
+ getType _ (L spn FunBind{fun_matches = MG _ in_tys out_typ _}) = return $ Just (spn, typ)
where typ = mkFunTys in_tys out_typ
#else
getType _ (L spn FunBind{fun_matches = MatchGroup _ typ}) = return $ Just (spn, typ)
What should we do?
Thank you for letting me know this. Would you add the VERSION_ghc cabal macro inside __GLASGOW_HASKELL__ >= 708 and give me a pull request? Thanks in advance.
I managed to work around it without using VERSION_ghc. Let me know what you think. Thanks!