dfithian / prune-juice

Prune unused Haskell dependencies.
MIT License
48 stars 4 forks source link

Incorrect results(on GHC 9.2.1?) #20

Closed LeventErkok closed 2 years ago

LeventErkok commented 2 years ago

Thanks for building this tool; something that was missing in the toolchain.

I tried to give it a try, but either it seems to produce incorrect results, or I'm not quite sure how to interpret the output. I tried it on this package: https://hackage.haskell.org/package/sbv

And it told me (amongst other things):

Some unused base dependencies for package sbv
  array
  async
  libBF
  pretty
  syb
  template-haskell
  transformers
  uniplate

I was skeptical, but still gave it a try after removing array from the cabal file dependencies, and of course the project no longer compiles due to the missing dependency.

Am I using the tool incorrectly?

dfithian commented 2 years ago

Did you compile your library first? https://github.com/dfithian/prune-juice#known-issues

LeventErkok commented 2 years ago

Yes; this is done right after a clean build via cabal new-build. (I don't use stack, but as I understand this shouldn't be a problem.)

I'm using GHC 9.2.1; if that makes a difference.

dfithian commented 2 years ago

Okay. Your ghc version could be the issue. I’ll try to get to this soon, I’m sorry you’re having the issue.

dfithian commented 2 years ago

Ps, I’m not sure if using -Wunused-packages will work for you, but that’s a new ghc feature and it could help. I’ll look into it regardless.

https://man.archlinux.org/man/community/ghc/ghc.1.en

LeventErkok commented 2 years ago

I already use that option; and it doesn't complain..

dfithian commented 2 years ago

Oh, okay, then I’m curious why you are using prune juice? Is it to apply the changes?

LeventErkok commented 2 years ago

When I first heard of prune-juice I misunderstood its goal; thought it would tell me if I defined a function in my package yet never used it anywhere else. Now I understand that's not what it does.

So yeah, I don't really need it I guess, given the existence of -Wunused-packages. But thought you'd wanna know regardless.

dfithian commented 2 years ago

Great, I appreciate you filing the issue and I will look into it.

dfithian commented 2 years ago

What’s your cabal version?

LeventErkok commented 2 years ago
$ cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal library
dfithian commented 2 years ago

Okay the issue seems to be that your cabal file is missing hs-source-dirs. I'll fix that assumption.

dfithian commented 2 years ago

This is the output I get now on the master branch of sbv:

$ prune-juice
Some unused dependencies for benchmark SBVBench in package sbv
  bench-show
  gauge
  silently
Some unused dependencies for benchmark SBVBenchmark in package sbv
  bench-show
  gauge
  silently

Not sure how these are used... but you may want to check the "known issues" section if these are still needed: https://github.com/dfithian/prune-juice#known-issues

dfithian commented 2 years ago

After running cabal build --enable-tests --enable-benchmarks (I get a lot of compile errors), I can now run prune-juice and there are no issues.

LeventErkok commented 2 years ago

Thanks.. It does make sense that these extra ones come from the benchmarks. (Which fail to compile due to dependency failures, but that's totally a separate issue.)