Skip to content

Are many public libraries allowed or not? #9480

@lsmor

Description

@lsmor

What is wrong with the docs?
In section library is very clearly claimed:

Currently, there can only be one publicly exposed library in a package, and its name is the same as package name set by global name field.

Whereas in the visibility section, a contradiction arises:

Can be public or private. Makes it possible to have multiple public libraries in a single package

Additional context
In my personal project I am trying to build two libraries within the same package. The main regular library (libA) and then a library with orphan quickcheck instances (libB). Test suite depends on both. So the cabal file is

cabal-version:      3.8
name: french-deck -- or libA if prefered
...

library  -- the regular main library
  ...

library french-deck-quickcheck -- or libB with Orphan instances
  ...
  build-depends:
      base >=4.16.4.0 && < 5,
      french-deck  -- depends on libA
  visibility: public -- public because I want to import these instances in other package
  
test-suite my-tests
    build-depends:
        base >=4.16.4.0 && < 5,
        french-deck,
        french-deck-quickcheck

I got the error below.

Resolving dependencies...
Error: cabal: Could not resolve dependencies:
[__0] trying: french-deck-0.1.0.0 (user goal)
[__1] trying: french-deck:*test
[__2] unknown package: french-deck-quickcheck (dependency of french-deck
*test)
[__2] fail (backjumping, conflict set: french-deck, french-deck-quickcheck,
french-deck:test)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: french-deck, french-deck:test,
french-deck-quickcheck

I am using cabal-install-3.8.1.0. At this point I don't know if multiple libraries are allowed or not and I have to define my instances in libA (which I wouldn't like)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions