Skip to content

Add support for visibility: public #382

Closed

Description

@expipiplus1

Thanks for the super tool!

It would be really nice to have support for multiple public libraries: https://fgaz.me/posts/2019-11-14-cabal-multiple-libraries/

At the moment it seems possible to do with verbatim: visibility: public as below, but it seems nasty to have to put these libraries in internal-libraries.

internal-libraries:
  foo:
    source-dirs: foo
    verbatim:
      visibility: public
    dependencies:
      - base < 4.14

Activity

  1. sol commented on Apr 30, 2020

    @sol
    Owner

    @expipiplus1 can you please try #385? Does this work for you?

  2. expipiplus1 commented on May 3, 2020

    @expipiplus1
    Author

    @sol, works great, thanks!

  3. Ptival commented on May 29, 2020

    @Ptival

    @expipiplus1 have you been able to import the exposed public library though?

    When I try putting package:library in a dependency field, hpack outputs package only.

  4. reopened this on May 29, 2020
  5. sol commented on May 29, 2020

    @sol
    Owner

    @Ptival I didn't have the need for this myself, but if having a dependency on a public library doesn't work then this is probably something we want to fix. If you can provide a minimal test case (as I understand it, we would need two packages for this, one that exports the library and one that depends on it), then I'll try to find the time to fix it.

  6. expipiplus1 commented on May 30, 2020

    @expipiplus1
    Author
  7. Ptival commented on May 30, 2020

    @Ptival

    Yes, it is indeed the other side of the picture.

    @sol

    In terms of minimal example, if you write a package.yaml like:

    dependencies:
      - base
      - package
      - package:library
    
    library:
      other-modules: []
    
    name: my-other-package
    
    verbatim:
      cabal-version: 3.0
    

    The output is:

    cabal-version: 3.0
    
    -- This file has been generated from package.yaml by hpack version 0.34.1.
    --
    -- see: https://github.com/sol/hpack
    
    name:           my-other-package
    version:        0.0.0
    build-type:     Simple
    
    library
      build-depends:
          base
        , package
      default-language: Haskell2010
    

    When it should be:

    cabal-version: 3.0
    
    -- This file has been generated from package.yaml by hpack version 0.34.1.
    --
    -- see: https://github.com/sol/hpack
    
    name:           my-other-package
    version:        0.0.0
    build-type:     Simple
    
    library
      build-depends:
          base
        , package
        , package:library
      default-language: Haskell2010
    

    Without it, my-other-package will not be able to import modules from package:library.

  8. sol commented on Jun 2, 2020

    @sol
    Owner

    For me

    dependencies:
      - base
      - package
      - package:library

    results in a parse error. @Ptival what version of hpack are you using?

    We want to address this, but for the meantime, this can be used as a workaround:

    dependencies:
      - base
      - package
      - name: package:library
  9. sol commented on Jun 2, 2020

    @sol
    Owner

    Ok, so the current behavior depends on the version of Cabal that hpack was built against.

  10. added a commit that references this issue on Jun 2, 2020
    1dc82f8
  11. Ptival commented on Jun 2, 2020

    @Ptival

    hpack-0.34.1, built with GHC 8.8.2 against Cabal-3.0.0.0.

    Thanks for the workaround! (it works)

  12. sol commented on Jun 2, 2020

    @sol
    Owner

    On Hackage as hpack-0.34.2. @Ptival you won't need to specify cabal-version: 3.0 anymore, hpack should infer it.

  13. Ptival commented on Jun 2, 2020

    @Ptival

    Sorry, turns out overriding hpack in nix is a bit of an adventure!

    I can confirm that it works, and inserts cabal-version properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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