4.16. Generating and compiling External Core Files

GHC can dump its optimized intermediate code (said to be in “Core” format) to a file as a side-effect of compilation. Non-GHC back-end tools can read and process Core files; these files have the suffix .hcr. The Core format is described in An External Representation for the GHC Core Language, and sample tools for manipulating Core files (in Haskell) are in the GHC source distribution directory under utils/ext-core. Note that the format of .hcr files is different from the Core output format that GHC generates for debugging purposes (Section 4.17, “Debugging the compiler”), though the two formats appear somewhat similar.

The Core format natively supports notes which you can add to your source code using the CORE pragma (see Section 7.13, “Pragmas”).

-fext-core

Generate .hcr files.

Currently (as of version 6.8.2), GHC does not have the ability to read in External Core files as source. If you would like GHC to have this ability, please make your wishes known to the GHC Team.