lua

Lua, an embeddable scripting language

https://hslua.org/

Version on this page:2.0.0
LTS Haskell 22.17:2.3.2
Stackage Nightly 2024-04-17:2.3.2
Latest on Hackage:2.3.2

See all snapshots lua appears in

MIT licensed by Albert Krewinkel
Maintained by Albert Krewinkel
This version can be pinned in stack with:lua-2.0.0@sha256:0fb5fcfeabf68a78cb83736b043c2963d0f2bdff3a6dcc5465225ae636b28e74,8039
Depends on 1 package(full list with versions):
Used by 2 packages in nightly-2021-10-29(full list with versions):

lua

Build status AppVeyor Status Hackage

The lua package provides a Lua interpreter as well as bindings, wrappers and types to combine Haskell and Lua.

Overview

Lua is a small, well-designed, embeddable scripting language. It has become the de-facto default to make programs extensible and is widely used everywhere from servers over games and desktop applications up to security software and embedded devices. This package provides Haskell bindings to Lua, enable coders to embed the language into their programs, making them scriptable.

Lua ships with the official Lua interpreter, version 5.3.6. Cabal flags allow to compile against a system-wide Lua installation instead, if desired.

Build flags

The following cabal build flags are supported:

  • system-lua: Use the locally installed Lua version instead of the version shipped as part of this package.

  • pkg-config: Use pkg-config to discover library and include paths. Setting this flag implies system-lua.

  • allow-unsafe-gc: Allow optimizations which make Lua’s garbage collection potentially unsafe; enabling this should be safe if there are no callbacks into Haskell during Lua garbage collection cycles. The flag should be disabled if Lua objects can have Haskell finalizers, i.e., __gc metamethods that call Haskell function.

    The flag is enabled per default, as Haskell functions are rarely used in finalizers. It can help to disable the flag if there are issues related to Lua’s garbage collection.

  • apicheck: Compile Lua with its API checks enabled.

  • lua_32bits: Compile Lua for a 32-bits system (e.g., i386, PowerPC G4).

  • export-dynamic: Add all symbols to dynamic symbol table; disabling this will make it possible to create fully static binaries, but renders loading of dynamic C libraries impossible.

  • hardcode-reg-keys: Don’t use CAPI to determine the names of certain registry key names but use hard coded values instead. This flag is required when compiling against Lua 5.3.3 or earlier, as those versions do not expose the necessary information in the @lauxlib.h@ header file. Setting this flag should usually be unproblematic, except if the used Lua version has been patched heavily.

Example: using a different Lua version

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

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

or with stack:

stack install pandoc --flag=lua:system-lua

Changes

Changelog

lua uses PVP Versioning.

lua 2.0.0

Release pending.

  • Module hierarchy moved from Foreign.Lua.Raw to Lua.

  • Documentation has been improved.

  • Added new function withNewState to run Lua operations.

  • New modules Lua.Ersatz containing all bindings to safe ersatz functions.

  • Higher level and enum types have been removed, only the low-level “code” types are kept in this package.

  • Constants are now represented as pattern synonyms like LUA_OK.

  • Provide bindings to more functions:

    • lua_is... type-checking functions;
    • lua_pushstring to push plain CStrings;
    • auxiliary functions
      • luaL_loadfile, and
      • luaL_loadfilex;
    • unsafe functions
      • lua_gettable,
      • lua_settable,
      • lua_getglobal, and
      • lua_setglobal.
  • The function lua_pop now expects a CInt instead of a StackIndex.

  • New StackIndex constructor functions nthTop, nthBottom, nth, and top.

  • Avoid unnecessary modification of HSFUN metatable.

  • Various cleanups and test improvements.

lua 1.0.0

Released 2021-02-18.

  • Initially created. Contains all modules in the Foreign.Lua.Raw hierarchy from hslua-1.3. Documentation has been improved.