thc:runtime
Copyright(C) 2026 Edward Kmett
LicenseUPL-1.0 AND BSD-3-Clause
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
PortabilityMagicHash, UnboxedTuples; GHC 9.14.1 finalizer ABI
Safe HaskellUnsafe
LanguageHaskell2010

THC.Internal.Weak

Description

Adapt a raw IO action to GHC's original automatic finalizer entry point. Raw state transformers are unsafe; the runtime owns their guest execution.

Synopsis

Automatic finalizer execution

runWeakFinalizer :: (State# RealWorld -> (# State# RealWorld, a #)) -> IO () Source #

Run an original State# RealWorld -> (# State# RealWorld, a #) action through GHC's automatic finalizer policy, discarding its lifted result without evaluating it. Each invocation runs the action once; the action remains reusable. This does not claim or retire a weak registration.

GHC labels the executing thread, reports action exceptions to its current finalizer exception handler, and ignores exceptions thrown by that handler. The handler is read when an exception occurs, not when this action is built. Callers must supply a genuine IO state transformer and retain its owning runtime context throughout execution; state tokens must not be fabricated.