hslua-1.0.3: Bindings to Lua, an embeddable scripting language

Copyright© 2007–2012 Gracjan Polak
2012–2016 Ömer Sinan Ağacan
2017-2019 Albert Krewinkel
LicenseMIT
MaintainerAlbert Krewinkel <tarleb+hslua@zeitkraut.de>
Stabilitybeta
Portabilitynon-portable (depends on GHC)
Safe HaskellNone
LanguageHaskell2010

Foreign.Lua.Util

Contents

Description

HsLua utility functions.

Synopsis

Documentation

getglobal' :: String -> Lua () Source #

Like getglobal, but knows about packages and nested tables. E.g.

getglobal' "math.sin"

will return the function sin in package math.

setglobal' :: String -> Lua () Source #

Like setglobal, but knows about packages and nested tables. E.g.

pushstring "0.9.4"
setglobal' "mypackage.version"

All tables and fields, except for the last field, must exist.

run :: Lua 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 :: Lua a -> IO (Either Exception 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.

raiseError :: Pushable a => a -> Lua NumResults Source #

Raise a Lua error, using the given value as the error object.

newtype Optional a Source #

Newtype wrapper intended to be used for optional Lua values. Nesting this type is strongly discouraged as missing values on inner levels are indistinguishable from missing values on an outer level; wrong values would be the likely result.

Constructors

Optional 

Fields

Instances
Pushable a => Pushable (Optional a) Source # 
Instance details

Defined in Foreign.Lua.Util

Methods

push :: Optional a -> Lua () Source #

Peekable a => Peekable (Optional a) Source # 
Instance details

Defined in Foreign.Lua.Util

Methods

peek :: StackIndex -> Lua (Optional a) Source #

getting values

peekEither :: Peekable a => StackIndex -> Lua (Either String a) Source #

Try to convert the value at the given stack index to a Haskell value. Returns Left with an error message on failure.

peekRead :: Read a => StackIndex -> Lua a Source #

Get a value by retrieving a String from Lua, then using readMaybe to convert the String into a Haskell value.

popValue :: Peekable a => Lua a Source #

Get, then pop the value at the top of the stack. The pop operation is executed even if the retrieval operation failed.