hslua- Bindings to Lua, an embeddable scripting language
Copyright© 2019-2020 Albert Krewinkel
MaintainerAlbert Krewinkel <albert+hslua@zeitkraut.de>
PortabilityRequires GHC 8 or later.
Safe HaskellNone



Utility functions for HsLua modules.



requirehs :: String -> Lua () -> Lua () Source #

Load a module, defined by a Haskell action, under the given name.

Similar to luaL_required: After checking "loaded" table, calls pushMod to push a module to the stack, and registers the result in package.loaded table.

The pushMod function must push exactly one element to the top of the stack. This is not checked, but failure to do so will lead to problems. Lua's package module must have been loaded by the time this function is invoked.

Leaves a copy of the module on the stack.

preloadhs :: String -> Lua NumResults -> Lua () Source #

Registers a preloading function. Takes an module name and the Lua operation which produces the package.

addfield :: Pushable a => String -> a -> Lua () Source #

Add a string-indexed field to the table at the top of the stack.

addfunction :: ToHaskellFunction a => String -> a -> Lua () Source #

Attach a function to the table at the top of the stack, using the given name.

create :: Lua () Source #

Create a new module (i.e., a Lua table).


data Module Source #

Named and documented Lua module.

data Field Source #

Self-documenting module field



registerModule :: Module -> Lua () Source #

Registers a Module; leaves a copy of the module table on the stack.

preloadModule :: Module -> Lua () Source #

Preload self-documenting module.


render :: Module -> Text Source #

Renders module documentation as Markdown.