0

I'm running into a compatibility problem trying to cabal install agda using GHC 7.8.3 and Cabal 1.16.0.2, on Ubuntu 14.04.

The problem appears to be with haskell-src-exts-1.15.0.1, which Agda requires. Compiling that library runs into the following well-known problem caused (I believe) by Happy-generated code being incompatible with a change to GHC in version 7.8.

templates/GenericTemplate.hs:104:22:
    Couldn't match expected type ‘Bool’
                with actual type ‘Happy_GHC_Exts.Int#’
    In the expression:
      (n Happy_GHC_Exts.<# (0# :: Happy_GHC_Exts.Int#))
    In a stmt of a pattern guard for
                   a case alternative:
      (n Happy_GHC_Exts.<# (0# :: Happy_GHC_Exts.Int#))
    In a case alternative:
        n | (n Happy_GHC_Exts.<# (0# :: Happy_GHC_Exts.Int#))
          -> (happyReduceArr Happy_Data_Array.! rule) i tk st
          where
              rule
                = (Happy_GHC_Exts.I#
                     ((Happy_GHC_Exts.negateInt#
                         ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))

The article mentioned above describes how to clean and rebuild a library that contains incompatible Happy-generated code. However, I couldn't make this work for haskell-src-exts-1.15.0.1. In particular, trying

cabal unpack haskell-src-exts-1.15.0.1 
cd haskell-src-exts-1.15.0.1
cabal clean
cabal install

runs into the same problem.

Any suggestions?

Roly
  • 2,126
  • 2
  • 20
  • 34
  • 1
    I couldn't reproduced the problem using Happy 1.19.4 (the above article says "Install the latest versions of alex and happy"). – asr Aug 03 '14 at 14:28
  • I installed happy-1.19.4 and alex-3.1.3, but still get the same problem. – Roly Aug 03 '14 at 16:56
  • 1
    FYI, I'm using cabal-install version 1.20.0.3 using version 1.20.0.1 of the Cabal library. Which is the output of the following commands: `cabal get haskell-src-exts`, `cd haskell-src-exts-1.15.0.1/`, `cabal clean` and `cabal configure -v`? – asr Aug 04 '14 at 01:14
  • 1
    I'm also using cpphs 1.18.5. – asr Aug 04 '14 at 01:44
  • Ok, thanks. I upgraded to cabal 1.20.0.3. The output of `cabal configure -v` is [here](http://pastie.org/9443688). Now I get [these errors](http://pastie.org/9443699) at roughly the same point in the compilation; maybe they shed some light on my problem? (I've checked and I have cpphs, polyparse and text already installed.) – Roly Aug 04 '14 at 07:32
  • I didn't see any problems in the output of `cabal configure -v`. Which is the output of `cabal install -v`? – asr Aug 04 '14 at 12:05
  • And which is the output of `ghc-pkg list`? – asr Aug 04 '14 at 13:01
  • Here is [`cabal install -v`](http://pastie.org/9444997), and also [`ghc-pck list`](http://pastie.org/9444999). – Roly Aug 04 '14 at 17:56
  • Also wondered whether [this](http://pastie.org/9445018) may help. – Roly Aug 04 '14 at 18:05
  • 1
    Reinstall all the libraries using cabal 1.20.0.3 (see https://ghc.haskell.org/trac/ghc/ticket/9060). – asr Aug 05 '14 at 02:50
  • Ok, that fixes my problem. Thanks. I had to do a `cabal install` of `text`, `polyparse` and `cpphs` (in that order), with options `--reinstall --force-reinstalls` (ignoring the warning). Feel free to summarise this in an answer. (If you do, please also mention the need to upgrade cabal, and include a link to the trac issue.) – Roly Aug 05 '14 at 06:58
  • It turned out that at least two other libraries (`hashtable` and `zlib`) were broken too and needed reinstalling. So in the end, safer simply to delete `~/.ghc` to force a rebuild of everything, as described in the trac issue. – Roly Aug 05 '14 at 07:14

1 Answers1

1

Short answer: Cabal 1.16.* is incompatible with GHC 7.8.3, so install a recent version of cabal-install (e.g. version 1.20.0.3), delete the directory associated to GHC 7.8.3 from ~/.ghc (e.g. x86_64-linux-7.8.3) and install everything again.

Long answer: See GHC issue 9060.

asr
  • 1,166
  • 6
  • 18