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.Interface

Description

Recover complete installed Core with the selected GHC 9.14.1 session.

Call loadInterfaceCore with an exact resolved unit/module and interface path, then interfaceCoreJSON to use THC's post-Tidy serialization. Missing complete Core is distinct from an invalid interface. Loading and archival serialization do not link native foreign products or authorize execution.

Synopsis

Documentation

data InterfaceCore Source #

Original GHC identities, declarations, recursive groups and foreign metadata. Loading is archival: accompanying foreign build products are retained, not linked or registered with a runtime.

interfaceModule :: InterfaceCore -> Module Source #

Original unit and module identity.

interfaceDetails :: InterfaceCore -> ModDetails Source #

Hydrated declarations from this interface.

interfaceBindings :: InterfaceCore -> CoreProgram Source #

Original groups plus missing local boxed-data wrappers.

interfaceForeign :: InterfaceCore -> IfaceForeign Source #

Foreign source and lifecycle metadata, retained without linking.

data InterfaceError Source #

Identity failure detected before Core hydration. Other malformed-interface and way/version failures retain GHC's own diagnostics.

Constructors

InterfaceModuleMismatch Module Module

Expected module, then actual interface owner.

loadInterfaceCore :: HscEnv -> Module -> FilePath -> IO (Maybe InterfaceCore) Source #

Read a raw installed interface with the selected GHC session's target, package database and NameCache. The expected Module includes the exact unit identity; callers must resolve it through that same session's package state. Nothing means only that this valid interface has no complete Core payload. Wrong identity, way/version and corrupt data are errors, not reasons to substitute ordinary inline unfoldings. Foreign products remain in the archive; successful hydration does not establish executable registration.

Use a session retaining interface pragmas from its creation when possible. Hydration retains pragmas in a private flags/environment value regardless; it does not change the caller's flags or install targets/bytecode. GHC's ordinary dependency loading can populate the session's shared caches.

interfaceCoreCBD :: [CommandLineOption] -> InterfaceCore -> IO ByteString Source #

Use the same serializer as the post-Tidy plugin, without another compile or a source target. Source-note paths survive even if source text is absent. This does not link dependencies or certify runtime support for the module.

interfaceCoreJSON :: [CommandLineOption] -> InterfaceCore -> IO String Source #

Explicit JSON inspection output. With "pretty-diagnostics", retain the rich producer model, including names, types and source Core; otherwise derive inspection from CBD. Never used for normal acquisition or execution.

interfaceCoreJSONBytes :: [CommandLineOption] -> InterfaceCore -> IO ByteString Source #

Byte-oriented version of interfaceCoreJSON, preserving its exact UTF-8 output. Force the strict result before emitting success to retain all-or-error subprocess responses if serialization fails.

probeInterface :: HscEnv -> Set String -> Set (String, String) -> Module -> FilePath -> IO (Fingerprint, Bool, Bool) Source #

Fingerprint the bytes retained by GHC's interface reader, including its tables, complete Core, annotations, foreign products and extensible fields. mi_iface_hash is insufficient: GHC excludes complete Core/foreign payloads from that recompilation hash. No Core hydration or JSON rendering occurs. Return the complete-byte fingerprint, payload availability and conservative demand eligibility. The caller also accounts for dependencies/source-note text.

checkInterfaceIdentity :: HscEnv -> Module -> FilePath -> IO () Source #

Check a home interface without hydrating Core or resolving installed dependencies. Compiler-discovered modules need their actual binary identity, not merely a neighboring .hi filename or a source-import guess.