diagrams / diagrams-contrib

User-contributed extensions to diagrams
BSD 3-Clause "New" or "Revised" License
27 stars 30 forks source link

diagrams-contrib 1.1.0.1 fails to compile due to missing Default instance #28

Closed rpglover64 closed 10 years ago

rpglover64 commented 10 years ago
[18 of 20] Compiling Diagrams.TwoD.Layout.Tree ( src/Diagrams/TwoD/Layout/Tree.hs, dist/dist-sandbox-14ce8ad3/build/Diagrams/TwoD/Layout/Tree.o )

src/Diagrams/TwoD/Layout/Tree.hs:448:26:
    No instance for (Default (ForceLayoutOpts R2))
      arising from a use of `def'
    Possible fix:
      add an instance declaration for (Default (ForceLayoutOpts R2))
    In the `_forceLayoutOpts' field of a record
    In the expression:
      FLTOpts
        {_forceLayoutOpts = def, _edgeLen = sqrt 2, _springK = 0.05,
         _staticK = 0.1}
    In an equation for `def':
        def
          = FLTOpts
              {_forceLayoutOpts = def, _edgeLen = sqrt 2, _springK = 0.05,
               _staticK = 0.1}
Failed to install diagrams-contrib-1.1.0.1
byorgey commented 10 years ago

Thanks for the report! I don't understand this error though (and I can't reproduce it). force-layout-0.3 provides an instance Fractional (Scalar v) => Default (ForceLayoutOpts v) which ought to apply here, and diagrams-contrib now requires force-layout >= 0.3, so I am not sure what is going on. Can you provide the output of ghc-pkg list?

rpglover64 commented 10 years ago

Interesting; I'd been installing in a sandbox, so I figured it wouldn't be a problem.

Here's a gist with the cabal install diagrams --dry-run and the cabal sandbox hc-pkg list output.

byorgey commented 10 years ago

Aha, I figured it out. You have the (old) package data-default-0.4.0 installed in your global package DB for some reason, so it is getting copied into your sandbox when you do cabal sandbox init. However, force-layout and other packages require the (new) data-default-class. After version 0.4, data-default split out the Default class into a separate package. So now you have both an old data-default and the new data-default-class which both provide a type class called Default; the error you are seeing is caused by a mismatch between the two different Default classes.

The best solution would be to unregister data-default-0.4.0 from your global package DB; I can see no good reason for wanting it there anyway. Alternatively, you can unregister it from your sandbox immediately after doing cabal sandbox init (but then you have to remember to do it every time).

I'm closing this ticket but feel free to add more comments here if you run into trouble/need more help/etc.

rpglover64 commented 10 years ago

Thank you! That... was surprisingly obscure. The reason I had data-default-0.4.0 installed is that the XMonad currently in Debian Jessie depends on it. I upgraded to the Sid packages, which use data-default-0.5.1.

Unfortunately, unregistering from within the sandbox tries to modify the global package database.

byorgey commented 10 years ago

Unfortunately, unregistering from within the sandbox tries to modify the global package database.

Ouch! I didn't know that. That seems like a bug. Anyway, glad you got it to work.

lambda-fairy commented 10 years ago

For posterity: I ran into this same issue (Ubuntu 14.04, GHC 7.6), but got it to build using

cabal install diagrams --constraint='data-default >= 0.5.2' --constraint='transformers installed'

data-default-0.5.2 is the first version that depends on data-default-class; I added the other constraint after cabal tried to reinstall transformers.

lambda-fairy commented 10 years ago

@byorgey Would it be a good idea to change diagrams-contrib to depend on data-default >= 0.5.2?

From what I see, it doesn't build with older versions anyway.

byorgey commented 10 years ago

If it doesn't build with older versions, then absolutely we should change the lower bound. On Sep 12, 2014 1:00 AM, "Chris Wong" notifications@github.com wrote:

@byorgey https://github.com/byorgey Would it be a good idea to change diagrams-contrib to depend on data-default >= 0.5.2?

From what I see, it doesn't build with older versions anyway.

— Reply to this email directly or view it on GitHub https://github.com/diagrams/diagrams-contrib/issues/28#issuecomment-55361741 .

bergey commented 10 years ago

I confirm that diagrams-contrib does not build with data-default-0.5.0 or earlier, and does with 0.5.2. I've made the change in master and on Hackage. @lfairy Thanks for reporting!