thc
Copyright(C) 2026 Edward Kmett
LicenseUPL-1.0 AND BSD-3-Clause
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
PortabilityGHC 9.14.1 compiler API
Safe HaskellNone
LanguageHaskell2010

THC.Plugin

Description

GHC 9.14.1 plugin and direct serializers for THC's executable Core format.

Use -fplugin=THC.Plugin with the output directory as the first plugin option. Package exports require post-tidy and unit-qualified; add source-notes to retain source-location metadata. The direct serializers consume genuine GHC Core and do not establish runtime support or link native foreign products. This library is tied to the selected GHC API version.

Synopsis

Documentation

plugin :: Plugin Source #

Export executable trees from GHC's Core pipeline. Without post-tidy the pass runs last before Tidy; that option selects the late plugin boundary after Tidy and before CorePrep, where package identities agree with emitted interfaces. The first option is the destination directory (default build/core). GHC compilations using the plugin are forced to recompile so the export is not silently skipped by native recompilation checks. pretty-diagnostics adds readable original Core to CBD inspection; it is off by default and independent of source-notes and executable representation facts.

For example, after making the plugin package visible to the selected GHC:

ghc -O2 -fplugin=THC.Plugin -fplugin-opt=THC.Plugin:build/core \
  -fplugin-opt=THC.Plugin:post-tidy -fplugin-opt=THC.Plugin:unit-qualified \
  -fplugin-opt=THC.Plugin:source-notes -c Example.hs

serializeOptimizedCore :: DynFlags -> [CommandLineOption] -> ModGuts -> IO String Source #

The same pre-Tidy serializer used by the plugin, without filesystem writes or closure registration. Callers must supply genuine optimized ModGuts.

serializePostTidyCore :: DynFlags -> [CommandLineOption] -> Module -> [TyCon] -> CoreProgram -> IfaceForeign -> IO String Source #

Serialize actual post-Tidy Core, including Core hydrated from a complete installed interface. JSON inspection is derived from CBD; optional original pretty Core remains output-only. "source-notes" and "unit-qualified" also affect this entry point. It neither writes files nor registers plugin closure roots. Foreign products are archival metadata, not executable registration. The schema bump prevents older runtimes/auditors from silently ignoring them.

serializePostTidyCoreWithAnnotations :: DynFlags -> [CommandLineOption] -> Module -> [TyCon] -> CoreProgram -> IfaceForeign -> [Annotation] -> IO String Source #

The installed-interface path retains typed module annotations. CgGuts in the late source plugin does not: use the emitted interface to recover this optional inventory, never a process-local table or a previous export file.

serializePostTidyCoreWithAnnotationsBytes :: DynFlags -> [CommandLineOption] -> Module -> [TyCon] -> CoreProgram -> IfaceForeign -> [Annotation] -> IO ByteString Source #

JSON inspection is an output-only view of the same typed binary artifact.