| Copyright | (C) 2026 Edward Kmett |
|---|---|
| License | UPL-1.0 AND BSD-3-Clause |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | experimental |
| Portability | GHC FFI; THC runtime services or native fallback implementation |
| Safe Haskell | Unsafe |
| Language | Haskell2010 |
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
- newtype ForeignException = ForeignException (Any :: Type)
- boxForeign :: (Any :: Type) -> SomeException
- projectForeign :: SomeException -> Any :: Type
- exceptionText :: Int -> ForeignException -> IO (Maybe String)
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) |
Instances
| Exception ForeignException # | |
Defined in THC.Internal.Exception Methods toException :: ForeignException -> SomeException # fromException :: SomeException -> Maybe ForeignException # | |
| Show ForeignException # | |
Defined in THC.Internal.Exception Methods showsPrec :: Int -> ForeignException -> ShowS # show :: ForeignException -> String # showList :: [ForeignException] -> ShowS # | |
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.