Haskell-OpenAPI-Code-Generator / Haskell-OpenAPI-Client-Code-Generator

Generate Haskell client code from an OpenAPI 3 specification
46 stars 19 forks source link

Generated package emits unused-packages warning #106

Closed chris-martin closed 4 months ago

chris-martin commented 4 months ago

One of the packages I'm generating seems to have no use of its unordered-containers dependency, resulting in a failure with stack build --pedantic.

<no location info>: error: [-Wunused-packages, -Werror=unused-packages]
    The following packages were specified via -package or -package-id flags,
    but were not needed for compilation:
      - unordered-containers-0.2.19.1-3PQQuRvgTJ8Dw2saM8VyGr

It would probably be hard to get the code generator to automatically produce a minimal dependency set, but perhaps there could be a setting in the configuration file to manually control which dependencies are included? I might submit a PR if this would be welcome.

Pretty simple workaround, though, is just to postprocess the cabal file.

sed -i '/\bunordered-containers\b/d' ./whatever.cabal
NorfairKing commented 4 months ago

@chris-martin You can also turn off -Wunused-packages for generated code. I have this in my stack.yaml:

ghc-options:
  "$locals": -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates -Wpartial-fields -Widentities -Wredundant-constraints -Wcpp-undef -O0 -Wunused-packages
  intray-stripe-client: -w # Turn off warnings for the generated code.
chris-martin commented 4 months ago

Oh thanks, I didn't realize you could add per-package flags in stack.yaml. This isn't a big deal then.