raiseError
: Its argument will be thrown as
an error in Lua.modifyLuaError
: The function lives in Foreign.Lua.Error and
allows to alter error messages. This is most useful for amending
errors with additional information.toList
which left a element on the stack if
deserializing that element lead to an error. This also affected the
FromLuaStack instance for lists.pairsFromTable
which left a key-value pair on the
stack if either of them could not be read into the expected type. This
also affected the FromLuaStack instance for Map.nthFromBottom
, nthFromTop
as well as the constants stackTop
and
stackBottom
have been introduced. Numeric constants are less clear,
and named constants can aid readability.idx
into an
equivalent absolute index (that is, one that does not depend on the
stack top). The function calls lua_absindex
when compiled with Lua
5.2 or later; for Lua 5.1, it is reimplemented in Haskell.tasty
which have been deprecated have been replaced
with non-deprecated alternatives.Foreign.Lua
: The typeclass
ToHaskellFunction
and the helper function toHaskellFunction
are
useful when working with functions. Importing them separately from
Foreign.Lua.FunctionCalling
was an unnecessary burden; they are
therefor now re-exported by the main module.refnil
and noref
: The constants
are related to Lua's registry functions (ref
and unref
).wrapHaskellFunction
is provided. It expects a
HaskellImportedFunction userdata (as produced by
pushHaskellFunction
) on top of the stack and replaces it with a C
function. The new function converts error values generated with
lerror
into Lua errors, i.e. it calls lua_error
.setglobal'
: It works like setglobal
, but
works with packages and nested tables (dot-notation only).toHaskellFunction
hinted at the fact that the failing function is a Haskell
function. This is mostly unnecessary information and might have confused
users.allow-unsafe-gc
is introduced and enabled by default.
Disabling this flag will mark more C API functions as potentially calling back
into Haskell. This has a serious performance impact.FromLuaStack
and ToLuaStack
instances for lazy ByteStrings are added.FromLuaStack
and ToLuaStack
for Int
are removed. The
correctness of these instances cannot be guaranteed if Lua was compiled with a
non-standard integer type.lua_32bits
was added to allow users to compile Lua for 32-bit
systems.FromLuaStack
and
ToLuaStack
.dostring
and dofile
are provided to load and run strings and
files in a single step.LuaStatus
was renamed to Status
, the Lua prefix was removed from its
type constructors.ErrFile
was added to Status
. It is returned by loadfile
if the file cannot be read.StackIndex
, NumArgs
, and NumResults
, but also the newly introduced
newtypes StatusCode
, TypeCode
, and LuaBool
.tointegerx
and tonumberx
which can be used to get and check
values from the stack in a single step.concat
was changed from Int -> Lua ()
to
NumArgs -> Lua ()
.loadfile
was changed from String -> Lua Int
to
String -> Lua Status
. LTYPE
was renamed to Type
, its constructors were renamed to
follow the pattern Type<Typename>
. LuaRelation
was renamed to
RelationalOperator
, the Lua prefix was removed from its constructors.tolist
to allow getting a generic list from the stack without
having to worry about the overlapping instance with [Char]
.use-pkgconfig
was added to allow discovery of library and include paths
via pkg-config. Setting a specific Lua version flag now implies system-lua
.
(Sean Proctor)Scripting.Lua
to Foreign.Lua
. The code is now
split over multiple sub-modules. Files processed with hsc2hs are restricted to
Foreign.Lua.Api.Lua
monad (reader monad over LuaState) is introduced. Functions which took
a LuaState as their first argument are changed into monadic functions within
that monad.longjmp
are now caught with the help of additional C wrapper
functions. Those no longer lead to uncontrolled program termination but are
converted into a LuaException.peek
no longer returns Maybe a
but just a
. A LuaException is thrown if
an error occurs (i.e. in situtations where Nothing would have been returned
previously).StackValue
typeclass has been split into FromLuaStack
and
ToLuaStack
. Instances not satisfying the law x == push x *> peek (-1)
have
been dropped.luaopen_base
, luaopen_package
, luaopen_string
,
luaopen_table
, luaopen_math
, luaopen_io
, luaopen_os
, luaopen_debug
and their high-level wrappers (with names openbase
, opentable
etc.)
implemented.loadfile
and loadstring
.tostring
function definition. (Sean Proctor)strlen
. (Sean Proctor)tolist
wasn't popping elements of the list from stack.pushstring
and tostring
now uses ByteString
instead of [Char]
.StackValue [Char]
instance is removed, StackValue ByteString
is added.StackValue a => StackValue [a]
instance is added. It pushes a Lua array to
the stack. pushlist
, islist
and tolist
functions are added.Scripting.Lua
documentation for detailed explanation. This should fix
segfaults reported several times.lua_error
function is removed, it's never safe to call in Haskell.Related issues and pull requests: #12, #26, #24, #23, #18.
extra-libraries
to link with Lua.luajit
flag is added to link hslua with LuaJIT.pushrawhsfunction
and registerrawhsfunction
functions are added.apicheck
flag is added to Cabal package to enable Lua API checking. (useful for debugging)luaL_ref
and luaL_unref
functions are added.