0

I'm trying to use Parsec's OperatorTable with the following:

table :: Ex.OperatorTable String () Identity Expr
table = [[]]

cabal build and cabal run work, but loading Main into GHCi gives me this weird error:

Parser.hs:127:33:
    Couldn't match type ‘Identity’
                  with ‘transformers-0.3.0.0:Data.Functor.Identity.Identity’
    NB: ‘Identity’
          is defined in ‘Data.Functor.Identity’
              in package ‘transformers-0.4.3.0’
        ‘transformers-0.3.0.0:Data.Functor.Identity.Identity’
          is defined in ‘Data.Functor.Identity’
              in package ‘transformers-0.3.0.0’
    Expected type: Ex.OperatorTable
                     String () transformers-0.3.0.0:Data.Functor.Identity.Identity Expr
      Actual type: Ex.OperatorTable String () Identity Expr
    In the first argument of ‘Ex.buildExpressionParser’, namely ‘table’
    In the expression: Ex.buildExpressionParser table factor

So I deleted ~/.cabal and .cabal-sandbox and reinstalled mtl, both globally and in a new sandbox Same error.

ghc-pkg list | grep trans gives:

transformers-0.3.0.0
transformers-0.4.3.0

so I tried ghc-pkg unregister transformers-0.3.0.0 but got a scary-looking warning message about how a bunch of other packages would break:

ghc-pkg: unregistering transformers-0.3.0.0 would break the following
packages: regex-posix-0.95.2 regex-compat-0.95.1 regex-base-0.93.2
parsec-3.1.5 network-2.4.2.3 mtl-2.1.3.1 fgl-5.5.0.1 HTTP-4000.2.10
ghc-7.8.3 haskeline-0.7.1.2 (use --force to override)

Didn't proceed.

Also tried ghci -package transformers-0.4.3.0 and got the same error.

What do I do now? :\

My .cabal file contains transformers <= 0.4.3.0. I'm on GHC 7.8.3 on OS X 10.10.2.

user1953221
  • 419
  • 1
  • 3
  • 9
  • 1
    why don't you constraint it to `transformers < 0.4.3.0` or even to `0.3.0.0`? It's hard to give you good advice if we don't see the "scary looking warning" - btw: did you start up ghci in your sandbox `cabal repl`? – Random Dev Apr 27 '15 at 05:29
  • Tried constraining it but didn't work also. I've edited the original post to include the warning. Starting with `cabal repl` worked but had some other problems, like not being able to see other modules in my project (trying to figure out why). I guess my question is: in general, how do I use newer versions of libraries and resolve such conflicts? – user1953221 Apr 27 '15 at 06:01
  • 1
    the problem is that normally you are not allowed have multiple versions of the same lib installed - you can in a sandbox but then you should tell GHCi to look there (`cabal repl` basically) – Random Dev Apr 27 '15 at 06:06
  • Okay, `cabal repl` worked after `cabal configure`. It respects all the settings in my `.cabal` file too, so that's awesome. Should I always prefer it over just using `ghci` and a `.ghci` file in the project root? Edit: ah, I get it. Thanks! – user1953221 Apr 27 '15 at 06:13
  • 2
    yes you should prefer it if you are using sandboxes :D – Random Dev Apr 27 '15 at 06:28

0 Answers0