hslua: A Lua language interpreter embedding in Haskell

[ foreign, library, mit ] [ Propose Tags ]

The Foreign.Lua module is a wrapper of Lua language interpreter as described on lua.org.

This package contains a full Lua interpreter version 5.3.4. If you want to link it with a system-wide Lua installation, use the system-lua flag.

Example programs are available in a separate repository.


[Skip to Readme]

Flags

Automatic Flags
NameDescriptionDefault
system-lua

Use the system-wide Lua instead of the bundled copy.

Disabled
apicheck

Compile Lua with -DLUA_USE_APICHECK.

Disabled
lua_32bits

Compile Lua with -DLUA_32BITS

Disabled
allow-unsafe-gc

Allow optimizations which make Lua's garbage collection potentially unsafe; haskell finalizers must be handled with extreme care.

Enabled
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.

Enabled
luajit

Link with LuaJIT. This implies flag system-lua as well.

Disabled
lua501

Build against lua 5.1.

Disabled
lua502

Build against lua 5.2.

Disabled
use-pkgconfig

Build using pkg-config to discover library and include paths. This is only used with system-lua and luajit.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1, 0.2, 0.3, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.6.1, 0.3.7, 0.3.8, 0.3.9, 0.3.10, 0.3.11, 0.3.12, 0.3.13, 0.4.0, 0.4.1, 0.5.0, 0.6.0, 0.7.0, 0.7.1, 0.8.0, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.9.5.1, 0.9.5.2, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.3.1, 1.0.3.2, 1.1.0, 1.1.1, 1.1.2, 1.2.0, 1.3.0, 1.3.0.1, 1.3.0.2, 2.0.0, 2.0.1, 2.1.0, 2.2.0, 2.2.1, 2.3.0, 2.3.1 (info)
Change log CHANGELOG.md
Dependencies base (>=4.7 && <5), bytestring (>=0.10.2 && <0.11), containers (>=0.5 && <0.6), exceptions (>=0.8 && <0.9), fail (>=4.9 && <5), mtl (>=2.2 && <2.3), text [details]
License MIT
Copyright © 2007–2012 Gracjan Polak © 2012–2016 Ömer Sinan Ağacan © 2016–2017 Albert Krewinkel
Author Gracjan Polak, Ömer Sinan Ağacan
Maintainer albert+hslua@zeitkraut.de
Category Foreign
Source repo head: git clone https://github.com/hslua/hslua.git
Uploaded by tarleb at 2017-10-22T21:00:09Z
Distributions Arch:2.3.0, Debian:1.0.3.2, Fedora:2.3.0, FreeBSD:0.4.0, LTSHaskell:2.3.1, NixOS:2.3.1, Stackage:2.3.1, openSUSE:2.3.1
Reverse Dependencies 17 direct, 169 indirect [details]
Downloads 143446 total (335 in the last 30 days)
Rating 2.5 (votes: 4) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-10-22 [all 1 reports]

Readme for hslua-0.9.2

[back to package description]

hslua – Lua interpreter interface for Haskell

Build Status AppVeyor Status Coverage Status Hackage

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

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 HsLua.

  • use-pkgconfig: Use pkg-config to discover library and include paths. This is used only when the system-lua flag is set or implied.

  • lua501: Build against Lua 5.1; this implies the flag system-lua as well.

  • lua502: Build against Lua 5.2; this implies the flag system-lua as well.

  • luajit: Build against LuaJIT; this implies the flag system-lua as well.

  • allow-unsafe-gc: Allow optimizations which make Lua's garbage collection potentially unsafe; haskell finalizers must be handled with extreme care. This is enabled per default, as this is rarely a problem in practice.

  • apicheck: Compile Lua with its API checks enabled.

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

Example: using a different lua version

To use a 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 +luajit". For example, you can install Pandoc with hslua that uses system-wide LuaJIT like this:

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

or with stack:

stack install pandoc --flag=hslua: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.

Why are there no predefined stack instances for default numerical types? HsLua defines instances for the FromLuaStack and ToLuaStack type-classes only if the following law holds: return x == push x *> peek x. Lua can be compiled with customized number types, making it impossible to verify the correctness of the above equation. Furthermore, instances for numerical types can be based on those of LuaInteger and LuaNumber and are easy to write. Therefor hslua doesn't provide any such instances.