@hackage hslua0.9.0
A Lua language interpreter embedding in Haskell
Installation
Dependencies (7)
- 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 Show all…
Dependents (20)
@hackage/oughta, @hackage/luautils, @hackage/pandoc-lua-marshal, @hackage/hslua-aeson, @hackage/CSPM-cspm, @hackage/hslua-module-version, Show all…
Package Flags
system-lua
(off by default)
Use the system-wide Lua instead of the bundled copy.
apicheck
(off by default)
Compile Lua with -DLUA_USE_APICHECK.
lua_32bits
(off by default)
Compile Lua with -DLUA_32BITS
allow-unsafe-gc
(on by default)
Allow optimizations which make Lua's garbage collection potentially unsafe; haskell finalizers must be handled with extreme care.
luajit
(off by default)
Link with LuaJIT. This implies flag system-lua as well.
lua501
(off by default)
Build against lua 5.1.
lua502
(off by default)
Build against lua 5.2.
use-pkgconfig
(off by default)
Build using pkg-config to discover library and include paths. This is only used with system-lua and luajit.
hslua – Lua interpreter interface for Haskell
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: Usepkg-configto discover library and include paths. This is used only when thesystem-luaflag is set or implied. -
lua501: Build against Lua 5.1; this implies the flagsystem-luaas well. -
lua502: Build against Lua 5.2; this implies the flagsystem-luaas well. -
luajit: Build against LuaJIT; this implies the flagsystem-luaas 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.