The hslua package

[ Tags: foreign, library, mit ] [ Propose Tags ]

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

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]


Versions 0.1, 0.2, 0.3, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6,, 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
Change log
Dependencies base (>=4.7 && <5), bytestring (>=0.10.2 && <0.11), containers (==0.5.*), exceptions (==0.8.*), fail (>=4.9 && <5), mtl (==2.2.*), 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
Category Foreign
Source repository head: git clone
Uploaded Wed Aug 16 07:42:02 UTC 2017 by tarleb
Distributions Arch:0.4.1, Debian:0.4.1, Fedora:0.4.1, FreeBSD:0.4.0, LTSHaskell:0.4.1, NixOS:0.8.0, Stackage:0.8.0, Tumbleweed:0.4.1
Downloads 65327 total (338 in the last 30 days)
Rating 2.0 (1 ratings) [clear rating]
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-08-16 [all 1 reports]
Hackage Matrix CI





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


Compile Lua with -DLUA_USE_APICHECK.


Compile Lua with -DLUA_32BITS


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


Build against lua 5.1.


Build against lua 5.2.


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


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


Maintainer's Corner

For package maintainers and hackage trustees

Readme for hslua-0.8.0

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

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"


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.