HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleforeign-store-0.2.1Haskell2010

Foreign.Store

Store a stable pointer in a foreign context to be retrieved later. Persists through GHCi reloads. Not thread-safe.

  • 2 types
  • 7 values

Foreign stores

9 declarations
valuewriteStore :: Store a -> a -> IO ()
#

Write to the store at the given index. If a store doesn't exist, creates one and resizes the store vector to fit. If there is already a store at the given index, deletes that store with deleteStore before replacing it.

Not thread-safe.

valuenewStore :: a -> IO (Store a)
#

Allocates or finds an unallocated store. The index is random. The internal vector of stores grows in size. When stores are deleted the vector does not shrink, but old slots are re-used.

Not thread-safe.

valuereadStore :: Store a -> IO a
#

Read from the store. If the store has been deleted or is unallocated, this will throw an exception.

Not thread-safe.

valuedeleteStore :: Store a -> IO ()
#

Frees the stable pointer for GC and frees up the slot in the store. Deleting an already deleted store is a no-op. But remember that store numbers are re-used.

Not thread-safe.

valuewithStore :: Store a -> (a -> IO b) -> IO b
#

Run the action with the value in the store.

Not thread-safe.

newtypenewtype Store a
#

A hideously unsafe store. Only for use if you are suave.

Constructors

Instances2Eq, Show
  • Eq (Store a)Defined in foreign-store-0.2.1 · Foreign.Store
  • Show (Store a)Defined in foreign-store-0.2.1 · Foreign.Store