thc:runtime
Copyright(C) 2026 Edward Kmett
LicenseUPL-1.0 AND BSD-3-Clause
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
PortabilityGHC FFI; THC runtime services or native fallback implementation
Safe HaskellUnsafe
LanguageHaskell2010

THC.Internal.Exception

Description

Private foreign-exception controls. Arbitrary pointers and foreign object construction are unsafe; use the abstract, typed THC.Exception interface instead.

Synopsis

Documentation

newtype ForeignException Source #

The runtime owns the opaque foreign object; this newtype gives it a genuine compiled Haskell Exception dictionary without exposing its representation.

Constructors

ForeignException (Any :: Type) 

boxForeign :: (Any :: Type) -> SomeException Source #

Wrap a runtime-owned foreign object with its compiled exception dictionary. Supplying an arbitrary Haskell value does not make it a valid foreign object. These helpers are compiled by GHC, including the actual existential dictionary and Typeable projection. Neither the runtime nor its tests forge SomeException.

projectForeign :: SomeException -> Any :: Type Source #

Recover the opaque object from a foreign exception, or return the internal unit-shaped sentinel for another exception. Only the runtime boundary may interpret this untyped result.

exceptionText :: Int -> ForeignException -> IO (Maybe String) Source #

Metadata inspection is effectful and may itself fail in the foreign language. The runtime publishes an immutable snapshot before indexing its codepoints. Concurrent first queries may inspect independently; the first published value wins.