- Clone my fork of PureScript and switch to
lua
branch:
➜ ~ git clone https://github.com/osa1/purescript.git purescript_lua_test
Cloning into 'purescript_lua_test'...
remote: Counting objects: 9089, done.
remote: Compressing objects: 100% (3362/3362), done.
remote: Total 9089 (delta 5625), reused 8886 (delta 5517)
Receiving objects: 100% (9089/9089), 1.75 MiB | 86.00 KiB/s, done.
Resolving deltas: 100% (5625/5625), done.
Checking connectivity... done
➜ ~ cd purescript_lua_test
➜ purescript_lua_test git:(master) git checkout lua
Branch lua set up to track remote branch lua from origin.
Switched to a new branch 'lua'
➜ purescript_lua_test git:(lua)
- Update your Cabal package DB for latest
language-lua
dependency, create a sandbox and install PureScript:
➜ purescript_lua_test git:(lua) cabal update
Downloading the latest package list from hackage.haskell.org
➜ purescript_lua_test git:(lua) cabal sandbox init
Writing a default package environment file to
/home/omer/purescript_lua_test/cabal.sandbox.config
Creating a new sandbox at /home/omer/purescript_lua_test/.cabal-sandbox
➜ purescript_lua_test git:(lua) cabal install
...
- Lua backend currently generates a file for every module compiled, so create a folder and move there to keep track of generated files easily:
➜ purescript_lua_test git:(lua) mkdir compiled_lua
➜ purescript_lua_test git:(lua) cd compiled_lua
- Compile an example program using Lua backend:
➜ compiled_lua git:(lua) ../.cabal-sandbox/bin/psc --lua --main Main ../examples/passing/TailCall.purs
➜ compiled_lua git:(lua) ✗ ls
Control_Monad_Eff.lua Control_Monad_ST.lua Data_Function.lua Main.lua Prelude_Unsafe.lua
Control_Monad_Eff_Unsafe.lua Data_Eq.lua Debug_Trace.lua Prelude.lua
- Run
Main.lua
with Lua 5.1, Lua 5.2 or LuaJIT 2.0.2.
Note that there are bugs(I just realized one while writing this post). If you find one, please tell me(osa1 @ Freenode) or open an issue at Github page.