hslua

A Lua language interpreter embedding in Haskell

Version on this page:0.6.0
LTS Haskell 22.17:2.3.1
Stackage Nightly 2024-04-19:2.3.1
Latest on Hackage:2.3.1

See all snapshots hslua appears in

MIT licensed by Gracjan Polak, Ömer Sinan Ağacan
Maintained by [email protected]
This version can be pinned in stack with:hslua-0.6.0@sha256:4b9560f68a0893886ac88eb963dd63e27b0edb87d1caaa7abb6cd24001b7dfab,7111

hslua – Lua interpreter interface for Haskell

Build Status Coverage Status Hackage

Hslua provides bindings, wrappers, types, and helper functions to bridge haskell and lua.

Using a different lua version

To use system-wide installed Lua/LuaJIT when linking hslua as a dependency, build/install your package using --constraint="hslua +system-lua" or for LuaJIT: --constraint="hslua +system-lua +luajit". For example, you can install Pandoc with hslua that uses system-wide LuaJIT like this:

cabal install pandoc --constraint="hslua +system-lua +luajit"

FAQ

Where are the coroutine related functions? Yielding from a coroutine works via longjmp, which plays very badly with Haskell’s RTS. Tests to get coroutines working with HsLua were unsuccessful. No coroutine related functions are exported from the default module for that reason. However, raw bindings to the C API functions are still provided in Foreign.Lua.RawBindings. If you get coroutines to work, or just believe that there should be wrapper functions for other reasons, we’d love to hear from you.

Changes

Changelog

0.5.0

  • New raw functions for 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.
  • Remove custom versions of loadfile and loadstring.
  • Drop support for GHC versions < 7.8, avoid compiler warnings.
  • Ensure no symbols are stripped when linking the bundled lua interpreter.
  • Simplify tostring function definition. (Sean Proctor)
  • Explicitly decprecate strlen. (Sean Proctor)
  • Add links to lua documentation for functions wrapping the official lua C API. (Sean Proctor).

0.4.1

  • Bugfix(#30): tolist wasn’t popping elements of the list from stack.

0.4.0

  • 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.
  • Type errors in Haskell functions now propagated differently. See the 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.

0.3.14

  • Pkgconf-based setup removed. Cabal is now using extra-libraries to link with Lua.
  • luajit flag is added to link hslua with LuaJIT.

0.3.13

  • Small bugfix related with GHCi running under Windows.

0.3.12

  • pushrawhsfunction and registerrawhsfunction functions are added.
  • apicheck flag is added to Cabal package to enable Lua API checking. (useful for debugging)

0.3.11

  • luaL_ref and luaL_unref functions are added.