ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHCi.RemoteTypes

Contents

- Remote pointer
- RemoteRef: reference to some heap object (potentially remote)
- ForeignRef: RemoteRef with a finalizer
- HValue

Description

Types for referring to remote objects in Remote GHCi. For more details, see Note [External GHCi pointers] in compilerGHCRuntime/Interpreter.hs

For details on Remote GHCi, see Note [Remote GHCi] in compilerGHCRuntime/Interpreter.hs.

Synopsis

- newtype RemotePtr (a :: k) = RemotePtr Word64
- toRemotePtr :: Ptr a -> RemotePtr a
- fromRemotePtr :: RemotePtr a -> Ptr a
- castRemotePtr :: forall {k1} {k2} (a :: k1) (b :: k2). RemotePtr a -> RemotePtr b
- newtype RemoteRef (a :: k) = RemoteRef (RemotePtr ())
- mkRemoteRef :: a -> IO (RemoteRef a)
- localRef :: RemoteRef a -> IO a
- freeRemoteRef :: forall {k} (a :: k). RemoteRef a -> IO ()
- castRemoteRef :: forall {k1} {k2} (a :: k1) (b :: k2). RemoteRef a -> RemoteRef b
- data ForeignRef (a :: k)
- mkForeignRef :: forall {k} (a :: k). RemoteRef a -> IO () -> IO (ForeignRef a)
- withForeignRef :: forall {k} (a :: k) b. ForeignRef a -> (RemoteRef a -> IO b) -> IO b
- finalizeForeignRef :: forall {k} (a :: k). ForeignRef a -> IO ()
- castForeignRef :: forall {k1} {k2} (a :: k1) (b :: k2). ForeignRef a -> ForeignRef b
- unsafeForeignRefToRemoteRef :: forall {k} (a :: k). ForeignRef a -> RemoteRef a
- newtype HValue = HValue (Any :: Type)
- type HValueRef = RemoteRef HValue
- type ForeignHValue = ForeignRef HValue

# Remote pointer

newtype RemotePtr (a :: k) Source #

Constructors

RemotePtr Word64 |

#### Instances

Instances details

Binary (RemotePtr a) Source # |
Instance details Defined in GHCi.RemoteTypes Methods put :: RemotePtr a -> Put Source # get :: Get (RemotePtr a) Source # putList :: [RemotePtr a] -> Put Source #
NFData (RemotePtr a) Source # |
Instance details Defined in GHCi.RemoteTypes Methods rnf :: RemotePtr a -> () Source #
Show (RemotePtr a) Source # |
Instance details Defined in GHCi.RemoteTypes Methods showsPrec :: Int -> RemotePtr a -> ShowS Source # show :: RemotePtr a -> String Source # showList :: [RemotePtr a] -> ShowS Source #

toRemotePtr :: Ptr a -> RemotePtr a Source #

fromRemotePtr :: RemotePtr a -> Ptr a Source #

castRemotePtr :: forall {k1} {k2} (a :: k1) (b :: k2). RemotePtr a -> RemotePtr b Source #

# RemoteRef: reference to some heap object (potentially remote)

newtype RemoteRef (a :: k) Source #

A reference to a heap object. Potentially in a remote heap! These are allocated and freed explicitly.

Constructors

RemoteRef (RemotePtr ()) |

#### Instances

Instances details

Binary (RemoteRef a) Source # |
Instance details Defined in GHCi.RemoteTypes Methods put :: RemoteRef a -> Put Source # get :: Get (RemoteRef a) Source # putList :: [RemoteRef a] -> Put Source #
Show (RemoteRef a) Source # |
Instance details Defined in GHCi.RemoteTypes Methods showsPrec :: Int -> RemoteRef a -> ShowS Source # show :: RemoteRef a -> String Source # showList :: [RemoteRef a] -> ShowS Source #

mkRemoteRef :: a -> IO (RemoteRef a) Source #

Make a reference to a local value that we can send remotely. This reference will keep the value that it refers to alive until `freeRemoteRef` is called.

localRef :: RemoteRef a -> IO a Source #

Convert a RemoteRef to its carried type. Should only be used if the RemoteRef originated in this process.

freeRemoteRef :: forall {k} (a :: k). RemoteRef a -> IO () Source #

Release a RemoteRef that originated in this process

castRemoteRef :: forall {k1} {k2} (a :: k1) (b :: k2). RemoteRef a -> RemoteRef b Source #

# ForeignRef: RemoteRef with a finalizer

data ForeignRef (a :: k) Source #

An RemoteRef with a finalizer

#### Instances

Instances details

NFData (ForeignRef a) Source # |
Instance details Defined in GHCi.RemoteTypes Methods rnf :: ForeignRef a -> () Source #

mkForeignRef :: forall {k} (a :: k). RemoteRef a -> IO () -> IO (ForeignRef a) Source #

Create a `ForeignRef` from a `RemoteRef`. The finalizer should arrange to call `freeRemoteRef` on the `RemoteRef`. (since this function needs to be called in the process that created the `RemoteRef`, it cannot be called directly from the finalizer).

withForeignRef :: forall {k} (a :: k) b. ForeignRef a -> (RemoteRef a -> IO b) -> IO b Source #

Use a `ForeignRef`

finalizeForeignRef :: forall {k} (a :: k). ForeignRef a -> IO () Source #

castForeignRef :: forall {k1} {k2} (a :: k1) (b :: k2). ForeignRef a -> ForeignRef b Source #

unsafeForeignRefToRemoteRef :: forall {k} (a :: k). ForeignRef a -> RemoteRef a Source #

# HValue

newtype HValue Source #

Constructors

HValue (Any :: Type) |

#### Instances

Instances details

Show HValue Source # |
Instance details Defined in GHCi.RemoteTypes Methods showsPrec :: Int -> HValue -> ShowS Source # show :: HValue -> String Source # showList :: [HValue] -> ShowS Source #

type HValueRef = RemoteRef HValue Source #

type ForeignHValue = ForeignRef HValue Source #