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's Foreign.Lua.Exceptions 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, and pushglobaltable.

    Any Haskell value can be pushed to the Lua stack as userdata via
    pushAny and retrieved via peekAny. 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 and preloadTableRegistryField,
    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 and rawseti 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, and touserdata, 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 and false
      are peeked as False, all other as True.

    Other

    • Many internal improvements and additions such as a benchmarking suite,
      โœ… code cleanups, better tests, etc.