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

within changes the behavior of modules: {as: } #1615

Open
parsonsmatt opened this issue Sep 6, 2024 · 1 comment
Open

within changes the behavior of modules: {as: } #1615

parsonsmatt opened this issue Sep 6, 2024 · 1 comment

Comments

@parsonsmatt
Copy link

We want to gradually become consistent with our naming of Data.List.NonEmpty, so we create an hlint rule:

- modules:
    - name: [Data.List.NonEmpty] 
      as: NE

I run hlint on our codebase to get all the currently failing examples, and I create a within to ignore them:

- modules:
    - name: [Data.List.NonEmpty] 
      as: NE
      within: [ ... ]

But now it starts complaining about importing Data.List.NonEmpty at all. It seems like within is causing it to ignore the as: key.

@zliu41
Copy link
Collaborator

zliu41 commented Dec 14, 2024

This is indeed very confusing, and I think there are two separate problems:

  1. when within is used, everything else including as is ignored, like you said
  2. To restrict importing a module itself, one must use within, otherwise the restriction won't apply (i.e., the import is allowed everywhere). But when restricting something else, such as module alias, within is not needed for the restriction to take effect (in fact you can't even use within because of the point above). The behaviors are inconsistent.

I'm marking this as a good first issue. The function that needs updating is Hint.Restrict.checkImports.

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

No branches or pull requests

2 participants