hslua-core-2.3.2: Bindings to Lua, an embeddable scripting language
Copyright© 2007–2012 Gracjan Polak;
© 2012–2016 Ömer Sinan Ağacan;
© 2017-2024 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb@hslua.org>
Stabilitybeta
Portabilitynon-portable (depends on GHC)
Safe HaskellSafe-Inferred
LanguageHaskell2010

HsLua.Core.Run

Description

Helper functions to run LuaE computations.

Synopsis

Documentation

run :: LuaE e a -> IO a Source #

Run Lua computation using the default HsLua state as starting point. Exceptions are masked, thus avoiding some issues when using multiple threads. All exceptions are passed through; error handling is the responsibility of the caller.

runEither :: Exception e => LuaE e a -> IO (Either e a) Source #

Run the given Lua computation; exceptions raised in Haskell code are caught, but other exceptions (user exceptions raised in Haskell, unchecked type errors, etc.) are passed through.

runWith :: State -> LuaE e a -> IO a Source #

Run Lua computation with the given Lua state. Exception handling is left to the caller; resulting exceptions are left unhandled.

GCManaged state

data GCManagedState Source #

Wrapper of a Lua state whose lifetime is managed by the Haskell garbage collector and has a finalizer attached. This means that the state does not have to be closed explicitly, but will be closed automatically when the value is garbage collected in Haskell.

newGCManagedState :: IO GCManagedState Source #

Creates a new Lua state that is under the control of the Haskell garbage collector.

closeGCManagedState :: GCManagedState -> IO () Source #

Closes the Lua state and runs all finalizers associated with it. The state _may not_ be used after it has been closed.

withGCManagedState :: GCManagedState -> LuaE e a -> IO a Source #

Runs a Lua action with a state that's managed by GC.