Dominik Schrempf
Dominik Schrempf

Reputation: 877

Handling of `.hie` files by Haskell Stack

I need to generate *.hie files for all of my Haskell module files in a project managed by Haskell Stack. I do this, by adding the -fwrite-ide-info compilation flag to stack.yaml in the following form:

ghc-options:
  "$locals": -fwrite-ide-info

Let's say the project consists of one package with a library and an executable. A stripped down package.cabal would be

name: package

library
  exposed-modules:
    Package.Exposed.Module
  ghc-options: -fwrite-ide-info

executable binary
  main-is: Main.hs
    ghc-options: -fwrite-ide-info
    build-depends:
      package

Then, I run stack build.

During the compilation, the *.hie files are generated in the .stack-work directory.

To be exact, respectively, the library and executable files are in

path/to/project/package/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/Package/...
path/to/project/package/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/binary/binary-tmp/...

I need the *.hie files in the actual source directories, and, low and behold, those *.hie files show up for the library, but not for the executable.

Now my question: How does Haskell Stack handle *.hie files. Are they handled in a special way, e.g., are they copied to the source files, where they can be found by programs making use of them (one such program that I want to use is weeder)? If not, I have no idea how those *.hie files showed up. Do you have any suggestions?

Thank you!

Upvotes: 3

Views: 610

Answers (1)

Dominik Schrempf
Dominik Schrempf

Reputation: 877

So, it seems that Haskell Stack does not copy/move hie files to the source folders. Maybe it did that at some point, because otherwise I have no idea how the files popped up there. After deletion of the hie files in the source folders, weeder actually uses the hie files in the .stack-work directories. I apologize for the confusion.

Upvotes: 1

Related Questions