tweag / gazelle_haskell_modules

A gazelle extension to generate haskell_module rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve the experience of deleting a source file

facundominguez opened this issue · comments

Deleting a source file requires currently a few interactions.

Run

$ cd example
$ nix-shell --pure --run "bazel run //:gazelle"
$ rm package-c/multiple-folder-src/PackageC/Exposed/E.hs

The first error we get is

$ nix-shell --pure --run "bazel run //:gazelle"
...
gazelle: himportscan: /home/facundo/tweag/gazelle_haskell_modules/example/package-c/multiple-folder-src/PackageC/Exposed/E.hs: openFile: does not exist (No such file or directory)
gazelle: exit status 1

which could be improved to point at the rule that has the missing file.

After removing the haskell_module rule that points at this file, gazelle succeeds.

$ nix-shell --pure --run "bazel test //..."
...
ERROR: /home/facundo/tweag/gazelle_haskell_modules/example/package-c/BUILD.bazel:57:16: in modules attribute of _haskell_library rule //package-c:package-c-multiple-srcs: target '//package-c:package-c-multiple-srcs.PackageC.Exposed.E' does not exist. Since this rule was created by the macro 'haskell_library', the error might have been caused by the macro implementation

After removing :package-c-multiple-srcs.PackageC.Exposed.E from the modules attribute of package-c-multiple-srcs we get

$ nix-shell --pure --run "bazel test //..."
...
ERROR: /home/facundo/tweag/gazelle_haskell_modules/example/package-c/BUILD.bazel:168:16: HaskellBuildObject //package-c:check-package-c-multiple-srcs //package-c:check-package-c-multiple-srcs.CheckPackageCMultipleSrcs failed: (Exit 1): ghc_wrapper failed: error executing command bazel-out/host/bin/external/rules_haskell/haskell/ghc_wrapper ... (remaining 2 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox

package-c/checksrc/CheckPackageCMultipleSrcs.hs:4:1: error:
    Could not find module ‘PackageC.Exposed.E’
...
  |
4 | import PackageC.Exposed.E ()
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

which finally requires fixing the code.

All of these steps multiplied by several removed files are rather tiresome.
The fix command should detect the removed files and update the configuration.