Skip to content

Unisay/purescript-lua

Repository files navigation

Purescript Backend for Lua

Purescript Lua CI

🔋 Status: (2023-07-05) the project is in the "ready to be experimented with" state (read: it likely contains bugs but is already usable).

💡 If you have an idea on how to use Purescript to Lua compilation please contribute it here: https://github.com/Unisay/purescript-lua/discussions/categories/ideas

Features

  • Lua code bundling: emits either a Lua module (a file that returns a table with functions) or an application (a file that executes itself).
  • FFI with Lua.
  • Dead Code Elimination (DCE).
  • Code inlining.
  • Package Set for PureScript/Lua libs.
  • All core libs added to the package set.

Quick Start

For the moment the best way to start is to use nix to intall pslua.

Consider configuring Cachix as a binary nix cache to avoid rebuilding a ton of dependencies:

cachix use purescript-lua

Here is an example project.

If you use Spago to build your PureScript project, then you can configure pslua as a custom backend like this:

spago.dhall

Assuming that pslua executable is already available on your PATH

{ name = "acme-project"
, dependencies = [ "effect", "prelude" ]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs" ]
, backend =
    ''
    pslua \
    --foreign-path . \
    --ps-output output \
    --lua-output-file dist/Acme_Main.lua \
    --entry Acme.Main
    ''
}

Using nix with flakes

nix run 'github:Unisay/purescript-lua' -- --help

Installation

If you're on a x86 64bit Linux system then you can download a pre-built executable from the releases page:

wget -c https://github.com/Unisay/purescript-lua/releases/download/0.1.1-alpha/pslua-linux_x86_64.tar.gz -O - | tar -xz

alternatively,

Using nix with flakes

nix profile install 'github:Unisay/purescript-lua'

will make pslua executable available for use.

About

Purescript compiler back-end for Lua

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •