hslua v1.0.0 Release Notes
Release Date: 2018-09-24 // over 5 years ago-
๐ New features
Error handling at language borders has been vastly improved and is now
๐ป mostly automatic. Haskell'sForeign.Lua.Exception
s are transformed
into Lua errors and vice versa. Lua-side wrappers are no longer
necessary.Haskell functions are no longer pushed as userdata by
pushHaskellFunction
, but as C functions. This simplifies tasks where
Lua expects true function objects object (for example when looking for
module loaders).โ Added stack instance for
- Data.Set.Set,
- Integer,
- Int,
- Float, and
- Double.
Instances for numbers fall back to strings when the
representation as a Lua number would cause a loss of precision.Haskell functions pushed with
pushHaskellFunction
can now be
garbage collected by Lua without having to call back into
Haskell. The callback into Haskell by the GC had previously
caused programs to hang in some situations.Bindings to more Lua C API functions and macros:
isinteger
,load
,
loadbuffer
, andpushglobaltable
.Any Haskell value can be pushed to the Lua stack as userdata via
pushAny
and retrieved viapeekAny
. Additional functions are
provided to setup the userdata metatable.The C preprocessor constants
LUA_LOADED_TABLE
and
LUA_PRELOAD_TABLE
are made available as
loadedTableRegistryField
andpreloadTableRegistryField
,
respectively.โ Additional small helper functions:
peekRead
-- read value from a string.popValue
-- peek value at the top of the Lua stack, then
โ remove it from the stack regardless of whether peeking was
successful or not.
Naming
The Lua prefix was removed from types (
State
,Integer
,Number
,
๐ปException
) and the respective infix from functions (try
,run
,
runWith
,runEither
). HsLua should be imported qualified to avoid
name collisions.๐ป Terminology now consistently uses exception to refer to Haskell
exceptions, and error for Lua errors; function names changed
accordingly (throwException
,catchException
,
withExceptionMessage
).Module Foreign.Lua.Api was renamed to Foreign.Lua.Core.
Foreign.Lua.lerror was renamed to Foreign.Lua.error.
Typeclass ToLuaStack was renamed to Pushable.
Typeclass FromLuaStack was renamed to Peekable.
๐ Cabal flag use-pkgconfig was renamed to pkg-config (which is the
flag name used by other projects such a zlib).Type signatures
๐ The return value of
lua_newuserdata
is CSize (was CInt).Table index parameter in
rawgeti
andrawseti
must be of type
LuaInteger, but were of type Int.The number of upvalues passed to
pushcclosure
must be of type
NumArgs.Lua.error
has type Lua NumResults, simplifying its use in
HaskellFunctions.Retrieval functions which can fail, i.e.
tocfunction
,tointeger
,
tonumber
,tostring
,tothread
, andtouserdata
, use the Maybe
type to indicate success or failure, avoiding the need to perform
โ additional checks.โ Removed Features
๐ Support for Lua versions before 5.3 has been dropped.
๐ Support for GHC 7.8 has been dropped.
wrapHaskellFunction
has been made internal and is no longer
exported.๐ Changed behavior
Peekable instances for numbers and strings became more forgiving.
0๏ธโฃ Peeking of basic types now follows Lua's default conversion rules:- numbers can be given as strings, and vice versa;
- any value can be converted into a boolean -- only
nil
andfalse
are peeked asFalse
, all other asTrue
.
Other
- Many internal improvements and additions such as a benchmarking suite,
โ code cleanups, better tests, etc.