You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's a bit of a confusing title, so hopefully this example makes it clear what I'm talking about. I want to run the benchmarks in vector-binary-instances, but Cabalgets mighty perplexed when trying to do so:
Preprocessing benchmark 'benchmarks' for vector-binary-instances-0.2.3.1...
[1 of 1] Compiling Main ( benchmarks/Benchmarks.hs, dist/build/benchmarks/benchmarks-tmp/Main.o )
benchmarks/Benchmarks.hs:41:50:
Overlapping instances for Binary (U.Vector Int)
arising from a use of ‘decode’
Matching instances:
instance (U.Unbox a, Binary a) => Binary (U.Vector a)
-- Defined in ‘vector-binary-instances-0.2.3.1@vecto_AfoM4V7e5UwKO3jo4zR1YO:Data.Vector.Binary’
instance (U.Unbox a, Binary a) => Binary (U.Vector a)
-- Defined in ‘Data.Vector.Binary’
In the first argument of ‘nf’, namely ‘(decode :: V)’
In the second argument of ‘($)’, namely ‘nf (decode :: V) bs’
In the expression: bench "U.Vector Int" $ nf (decode :: V) bs
benchmarks/Benchmarks.hs:48:40:
Overlapping instances for Binary (U.Vector Int)
arising from a use of ‘encode’
Matching instances:
instance (U.Unbox a, Binary a) => Binary (U.Vector a)
-- Defined in ‘vector-binary-instances-0.2.3.1@vecto_AfoM4V7e5UwKO3jo4zR1YO:Data.Vector.Binary’
instance (U.Unbox a, Binary a) => Binary (U.Vector a)
-- Defined in ‘Data.Vector.Binary’
In the first argument of ‘nf’, namely ‘encode’
In the second argument of ‘($)’, namely ‘nf encode vec1’
In the expression: bench "U.Vector Int 3" $ nf encode vec1
What's confusing about the error message is that the "overlapping" instances both come from Data.Vector.Binary! I think Cabal might be getting tripped up over the fact that the benchmark depends on criterion, but criterion transitively depends on vector-binary-instances itself.
That being said, I don't know what the correct behavior is for this scenario. Should Cabal prevent you from even attempting to build the benchmark? Or is there some way to make this work?
The text was updated successfully, but these errors were encountered:
If you added the full log from Cabal it probably had a warning saying that the versions are inconsistent. Cabal doesn't enforce strong consistency so that you can manually configure a cycle like this (but it is definitely a "you get to keep all the pieces" type situation.) Enforcing consistency is the package manager's job.
You didn't mention it here, but Stack has a hack to allow cyclic dependencies like this (c.f. commercialhaskell/stack#220). So they purposely configured the benchmark suite with two different versions of the package. But since vector-binary-instances defines orphan instances, this is just not going to work; you really need only one vector-binary-instances in the plan. My expert recommendation is to have vector-binary-instances split out the implementation from the instances, and then in the test suite not use the instances to test (just call the implementation directly.)
For reference, cabal-install would reject this install plan. There's a PR to relax this #3290 but it is still buggy.
Oh, I see what went wrong. I had installed vector-binary-instances before running cabal configure --enable-benchmarks, so Cabal never warned me about the inconsistent versions. If I first create a sandbox and then try cabal install --enable-benchmarks, it errors.
Sorry for the noise! I'll close this as a duplicate of #1575, and try out your advice for fixing vector-binary-instances.
That's a bit of a confusing title, so hopefully this example makes it clear what I'm talking about. I want to run the benchmarks in
vector-binary-instances
, butCabal
gets mighty perplexed when trying to do so:What's confusing about the error message is that the "overlapping" instances both come from
Data.Vector.Binary
! I thinkCabal
might be getting tripped up over the fact that the benchmark depends oncriterion
, butcriterion
transitively depends onvector-binary-instances
itself.That being said, I don't know what the correct behavior is for this scenario. Should
Cabal
prevent you from even attempting to build the benchmark? Or is there some way to make this work?The text was updated successfully, but these errors were encountered: