Changelog History
Page 2
-
v1.0.1 Changes
October 03, 2018๐ฆ Exposed more functions from Lua's
lauxlib
library:getmetafield
,getmetatable'
,getsubtable
, andtraceback
.
The function
getsubtable
is a reimplementation instead of a wrapper
to the C function for simplicity (thereby avoiding additional C
wrappers).๐ Fixed tests for GHC 8.6 by no longer depending on failable pattern
matching. -
v1.0.0 Changes
September 24, 2018๐ 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.
-
v0.9.6
May 11, 2018 -
v0.9.5 Changes
April 10, 2018- Provide Optional as a replacement for OrNil. Exports of the latter have been fixed.
- ๐ Provide utility function
raiseError
: Its argument will be thrown as an error in Lua. - โ Add
modifyLuaError
: The function lives in Foreign.Lua.Error and allows to alter error messages. This is most useful for amending errors with additional information. - ๐ Fixed a bug in
toList
which left a element on the stack if deserializing that element lead to an error. This also affected the FromLuaStack instance for lists. - ๐ Fixed a bug in
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.
-
v0.9.5.2 Changes
July 28, 2018- Relaxed upper bounds on exceptions.
-
v0.9.5.1
April 10, 2018 -
v0.9.4 Changes
- ๐ Make Lua an instance of MonadMask: MonadMask from Control.Monad.Catch allows to mask asynchronous exceptions. This allows to define a finalizer for Lua operations.
- โ Add functions and constants to refer to stack indices: The functions
nthFromBottom
,nthFromTop
as well as the constantsstackTop
andstackBottom
have been introduced. Numeric constants are less clear, and named constants can aid readability. - โ Add type OrNil: This type can be used when dealing with optional arguments to Lua functions.
- โ Add function absindex: it converts the acceptable index
idx
into an equivalent absolute index (that is, one that does not depend on the stack top). The function callslua_absindex
when compiled with Lua 5.2 or later; for Lua 5.1, it is reimplemented in Haskell. - ๐ Functions in
tasty
which have been deprecated have been replaced with non-deprecated alternatives.
-
v0.9.3 Changes
- Re-export more FunctionCalling helpers in
Foreign.Lua
: The typeclassToHaskellFunction
and the helper functiontoHaskellFunction
are useful when working with functions. Importing them separately fromForeign.Lua.FunctionCalling
was an unnecessary burden; they are therefor now re-exported by the main module. - Export registry-relatd constants
refnil
andnoref
: The constants are related to Lua's registry functions (ref
andunref
). - โ Add helper to convert functions into CFunction: A new helper
wrapHaskellFunction
is provided. It expects a HaskellImportedFunction userdata (as produced bypushHaskellFunction
) on top of the stack and replaces it with a C function. The new function converts error values generated withlerror
into Lua errors, i.e. it callslua_error
. - โ Add utility function
setglobal'
: It works likesetglobal
, but works with packages and nested tables (dot-notation only).
- Re-export more FunctionCalling helpers in
-
v0.9.2 Changes
- โ Add cabal flag 'export-dynamic': Default behavior is to include all symbols in the dynamic symbol table, as this enables users to load dynamic lua libraries. However, it is sometimes desirable to disable, e.g., when compiling a fully static binary. See jgm/pandoc#3986.
-
v0.9.1 Changes
- Increase user-friendlyness of error messages: The error message returned by
toHaskellFunction
hinted at the fact that the failing function is a Haskell function. This is mostly unnecessary information and might have confused users.
- Increase user-friendlyness of error messages: The error message returned by