| Copyright | (C) 2026 Edward Kmett |
|---|---|
| License | UPL-1.0 AND BSD-3-Clause |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | experimental |
| Portability | GHC 9.14.1 compiler API |
| Safe Haskell | None |
| Language | Haskell2010 |
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
- data InterfaceCore
- interfaceModule :: InterfaceCore -> Module
- interfaceDetails :: InterfaceCore -> ModDetails
- interfaceBindings :: InterfaceCore -> CoreProgram
- interfaceForeign :: InterfaceCore -> IfaceForeign
- data InterfaceError = InterfaceModuleMismatch Module Module
- loadInterfaceCore :: HscEnv -> Module -> FilePath -> IO (Maybe InterfaceCore)
- interfaceCoreCBD :: [CommandLineOption] -> InterfaceCore -> IO ByteString
- interfaceCoreJSON :: [CommandLineOption] -> InterfaceCore -> IO String
- interfaceCoreJSONBytes :: [CommandLineOption] -> InterfaceCore -> IO ByteString
- probeInterface :: HscEnv -> Set String -> Set (String, String) -> Module -> FilePath -> IO (Fingerprint, Bool, Bool)
- checkInterfaceIdentity :: HscEnv -> Module -> FilePath -> IO ()
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. |
Instances
| Exception InterfaceError # | |
Defined in THC.Interface Methods toException :: InterfaceError -> SomeException # fromException :: SomeException -> Maybe InterfaceError # displayException :: InterfaceError -> String # backtraceDesired :: InterfaceError -> Bool # | |
| Show InterfaceError # | |
Defined in THC.Interface Methods showsPrec :: Int -> InterfaceError -> ShowS # show :: InterfaceError -> String # showList :: [InterfaceError] -> ShowS # | |
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.