Copyright | © 2019-2020 Albert Krewinkel |
---|---|
License | MIT |
Maintainer | Albert Krewinkel <albert+hslua@zeitkraut.de> |
Stability | alpha |
Portability | Requires GHC 8 or later. |
Safe Haskell | None |
Language | Haskell2010 |
Utility functions for HsLua modules.
Synopsis
- requirehs :: String -> Lua () -> Lua ()
- preloadhs :: String -> Lua NumResults -> Lua ()
- addfield :: Pushable a => String -> a -> Lua ()
- addfunction :: ToHaskellFunction a => String -> a -> Lua ()
- create :: Lua ()
- data Module = Module {
- moduleName :: Text
- moduleDescription :: Text
- moduleFields :: [Field]
- moduleFunctions :: [(Text, HaskellFunction)]
- data Field = Field {
- fieldName :: Text
- fieldDescription :: Text
- fieldPushValue :: Lua ()
- registerModule :: Module -> Lua ()
- preloadModule :: Module -> Lua ()
- pushModule :: Module -> Lua ()
- render :: Module -> Text
Documentation
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.
Module
Named and documented Lua module.
Module | |
|
Self-documenting module field
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.
pushModule :: Module -> Lua () Source #