Skip to content

Cabal gets confused by benchmark stanza with a dependency that depends on the library itself #3366

Closed
@RyanGlScott

Description

@RyanGlScott

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 Cabal gets 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions