ghc-lib-parser-9.14.1.20251220: 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) #

Constructors

RemotePtr Word64 |

#### Instances

Instances details

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

toRemotePtr :: Ptr a -> RemotePtr a #

fromRemotePtr :: RemotePtr a -> Ptr a #

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

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

newtype RemoteRef (a :: k) #

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

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

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 #

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 () #

Release a RemoteRef that originated in this process

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

# ForeignRef: RemoteRef with a finalizer

data ForeignRef (a :: k) #

An RemoteRef with a finalizer

#### Instances

Instances details

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

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

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 #

Use a `ForeignRef`

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 #

# HValue

newtype HValue #

Constructors

HValue (Any :: Type) |

#### Instances

Instances details

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

type HValueRef = RemoteRef HValue #

type ForeignHValue = ForeignRef HValue #