wasmedge-hs-0.17.1.0: Haskell bindings for the WasmEdge WebAssembly runtime
Copyright(c) 2026 Tushar Adhatrao
LicenseMIT
Stabilitystable
Safe HaskellNone
LanguageGHC2021

WasmEdge.Global

Description

Provides contexts for WebAssembly global variables:

Synopsis

Global type

data GlobalType #

A WebAssembly global type context, describing its type and mutability.

createGlobalType :: ValType -> Mutability -> IO GlobalType #

Create a GlobalType with the specified ValType and Mutability.

deleteGlobalType :: GlobalType -> IO () #

Delete a GlobalType context.

withGlobalType :: ValType -> Mutability -> (GlobalType -> IO a) -> IO a #

Scoped GlobalType context.

Global instance

data GlobalInstance #

A runtime WebAssembly global variable instance.

createGlobal :: GlobalType -> WasmVal -> IO GlobalInstance #

Create a GlobalInstance with the given type and initial value.

getGlobalType :: GlobalInstance -> IO GlobalType #

Get the GlobalType of a GlobalInstance. Note: the returned GlobalType borrows the type context from the instance.

getGlobalValue :: GlobalInstance -> IO WasmVal #

Get the current value of a global variable.

setGlobalValue :: GlobalInstance -> WasmVal -> IO (WasmResult ()) #

Set a new value for a mutable global variable. Fails with a WasmEdgeError if the global is immutable or type mismatches.

Internal / borrowed pointers

borrowGlobal :: Ptr GlobalInstanceTag -> IO GlobalInstance #

Create a borrowed GlobalInstance from a raw pointer (does not finalize).

unsafeGlobalTypePtr :: GlobalType -> IO (Ptr GlobalTypeTag) #

Extract the raw pointer of a GlobalType.

borrowGlobalType :: Ptr GlobalTypeTag -> IO GlobalType #

Create a borrowed GlobalType from a raw pointer (does not finalize).

disarmGlobal :: GlobalInstance -> IO () #

Disarm finalizer when ownership is transferred to a module instance.