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

Re-exports can't be roots? #74

Open
tomjaguarpaw opened this issue May 16, 2021 · 0 comments
Open

Re-exports can't be roots? #74

tomjaguarpaw opened this issue May 16, 2021 · 0 comments

Comments

@tomjaguarpaw
Copy link
Contributor

I'm confused by the behaviour of weeder around re-exports. For example

  • B defines not_a_weed
  • A imports B and re-exports not_a_weed
  • A.not_a_weed is set as a root

Yet B.not_a_weed is detected as a weed. Is this expected behaviour? If so can I get the behaviour that I want? To put this in a more realistic context I want to use weeder on Opaleye by setting all functions in Opaleye (and a couple of other modules) to be roots.

This seems to be related to #40. In fact resolving that issue would probably solve my problem. But it seems that even without a feature to mark every export from a module as a root marking an individual re-export should mark its original definition as used.

--- weeder-example.cabal
cabal-version:      2.4
name:               weeder-example
version:            0.1.0.0

library
    exposed-modules:  A, B
    build-depends:    base
    hs-source-dirs:   src
    default-language: Haskell2010

--- cabal.project.local
package *
  ghc-options: -fwrite-ide-info

--- weeder.dhall
-- To run it:
-- ~/.ghcup/bin/cabal clean && ~/.ghcup/bin/cabal build  --with-ghc /opt/ghc/8.10.2/bin/ghc  all && ~/.cabal/bin/weeder-8.10

{ roots = [ "^B.not_a_weed$" ]
, type-class-roots = True }

--- src/A.hs
module A where

not_a_weed :: Int
not_a_weed = 1

--- src/B.hs
module B (not_a_weed) where

import A

% ~/.cabal/bin/weeder-8.10
src/A.hs:4:1: error: not_a_weed is unused

       2 ┃
       3 ┃ not_a_weed :: Int
       4 ┃ not_a_weed = 1

    Delete this definition or add ‘A.not_a_weed’ as a root to fix this error.


Weeds detected: 1
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

1 participant