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

WasmEdge.Executor

Description

The Executor context executes WebAssembly instructions, manages module instantiation, and invokes exported functions. It works together with Store.

For the simplest usage, consider using the high-level VM API instead.

Synopsis

Executor context

data Executor #

Low-level execution context.

createExecutor :: Maybe Configure -> Maybe Statistics -> IO Executor #

Create an Executor with optional configuration and statistics contexts.

deleteExecutor :: Executor -> IO () #

Delete an Executor.

AST module context

newtype ASTModule #

Parsed WebAssembly Abstract Syntax Tree module.

loadASTFromFile :: FilePath -> IO (WasmResult ASTModule) #

Load and parse an ASTModule from a WASM file on disk.

loadASTFromBytes :: ByteString -> IO (WasmResult ASTModule) #

Load and parse an ASTModule from an in-memory WASM binary.

withASTModule :: ASTModule -> (ASTModule -> IO a) -> IO a #

Scoped ASTModule.

validateAST :: ASTModule -> IO (WasmResult ()) #

Validate an ASTModule.

Instantiation and registration

instantiateModule :: Executor -> Store -> ASTModule -> IO (WasmResult ModuleInstance) #

Instantiate an ASTModule into a Store, returning the new ModuleInstance.

registerModule :: Executor -> Store -> ASTModule -> Text -> IO (WasmResult ModuleInstance) #

Instantiate and register an ASTModule under an export name into a Store.

registerImportModule :: Executor -> Store -> ModuleInstance -> IO (WasmResult ()) #

Register a pre-created ModuleInstance (e.g. host module or WASI) into a Store.

registerImportModuleWithAlias :: Executor -> Store -> ModuleInstance -> Text -> IO (WasmResult ()) #

Register a pre-created ModuleInstance under a custom alias name into a Store.

Function invocation

invokeFunction :: Executor -> FunctionInstance -> [WasmVal] -> IO (WasmResult [WasmVal]) #

Synchronously invoke a FunctionInstance with arguments, returning results.

asyncInvokeFunction :: Executor -> FunctionInstance -> [WasmVal] -> IO Async #

Asynchronously invoke a FunctionInstance, returning an Async handle.

Internal / borrowed pointers

unsafeExecutorPtr :: Executor -> IO (Ptr ExecutorTag) #

Extract the raw pointer of an Executor.

borrowExecutor :: Ptr ExecutorTag -> IO Executor #

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

unsafeASTModulePtr :: ASTModule -> IO (Ptr ASTModuleTag) #

Extract the raw pointer of an ASTModule.

borrowASTModule :: Ptr ASTModuleTag -> IO ASTModule #

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