Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please, how to add a package name into mixin? #453

Open
Anton-Latukha opened this issue Sep 20, 2021 · 2 comments
Open

Please, how to add a package name into mixin? #453

Anton-Latukha opened this issue Sep 20, 2021 · 2 comments

Comments

@Anton-Latukha
Copy link

Anton-Latukha commented Sep 20, 2021

For example, the main way to setup relude is:
(in the form of Cabal specification):

 mixins:
    base hiding (Prelude)
  , relude (Relude as Prelude)
  , relude

Full example:

  build-depends:
      base
    , relude

  mixins:
      base hiding (Prelude)
    , relude (Relude as Prelude)
    , relude

HPack allows to:

  - name: base
    mixin:
      - hiding (Prelude)
  - name: relude
    mixin:
      - (Relude as Prelude)

But into Cabal it gets translated as:

  build-depends:
    - relude

  mixins:
      base hiding (Prelude)
    , relude (Relude as Prelude)

Which has unexpected behavior - any modules except main Relude module from the tree of relude modules can not be imported.

If only there was a documented way, or if I knew the way to do something like:

  - name: base
    mixin:
      - hiding (Prelude)
  - name: relude
    mixin:
      - (Relude as Prelude)
      - 
      # (or)
      - relude
      # (or)
    - mixin

To put that - relude the second time - it all seems to work fine then if that gets possible.

@Anton-Latukha Anton-Latukha changed the title How to add a package name into mixin How to add a package name into mixin? Sep 20, 2021
@Anton-Latukha Anton-Latukha changed the title How to add a package name into mixin? Please, how to add a package name into mixin? Sep 20, 2021
@philderbeast
Copy link
Contributor

@Anton-Latukha I'm doing something similar with ghc-corroborate. Adding a hiding () item could get you what you want.

-- package.dhall
                , dependencies =
                  [ { name = "ghc"
                    , version = ">=8.0 && <8.2"
                    , mixin =
                      [ "hiding ()"
                      , "(TcRnTypes as TcRnTypes)"
                      , "(Type as Type)"
                      , "(TcRnTypes as Constraint)"
                      , "(Type as Predicate)"
                      ]
                    }
                  ]
# generated from package.dhall with "dhall-hpack-yaml > package.yaml"
    dependencies:
    - name: ghc
      version: '>=8.0 && <8.2'
      mixin:
      - hiding ()
      - (TcRnTypes as TcRnTypes)
      - (Type as Type)
      - (TcRnTypes as Constraint)
      - (Type as Predicate)
-- generated ghc-corroborate.cabal with "dhall-hpack-cabal"
    build-depends:
        ghc >=8.0 && <8.2
    mixins:
        ghc hiding ()
      , ghc (TcRnTypes as TcRnTypes)
      , ghc (Type as Type)
      , ghc (TcRnTypes as Constraint)
      , ghc (Type as Predicate)

@philderbeast
Copy link
Contributor

I tried adding an empty string entry and this adds the dependency to the mix as-is.

# package.yaml
    dependencies:
    - name: ghc
      version: '>=8.0 && <8.2'
      mixin:
      - ''
-- generated ghc-corroborate.cabal
    build-depends:
        ghc >=8.0 && <8.2
    mixins:
        ghc 

philderbeast added a commit to cabalism/hpack that referenced this issue Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants