Haskell: How to generate a .hi file using ghc?

I would like to create an interface file .hiand only that (without an object file, no code generation at all).

I tried

ghc -fno-code -ohi out.hi myfile.hs

and get

ghc: -ohi can only be used when compiling a single source file

which I do not understand, since I gave only one source file.

+4
source share
2 answers

Around 2014, an option was added to the GHC for this. Now you can call:

ghc -fno-code -fwrite-interface ...

In some cases, this speeds up compilation by about a quarter.

+2
source

Use the parameter -c, otherwise ghc wants to bind, not just for compilation:

ghc -fno-code -ohi out.hi -c myfile.hs

UPDATE: , -fno-code .hi.

ghc -o /dev/null -ohi out.hi -c myfile.hs

. , , out.hi .

+2

All Articles