Git Product home page Git Product logo

idris2-lua's Introduction

Lua backend for Idris 2


Tested against Idris 2, version 0.5.1-96c44abb6

Requirements & Installation

All libraries can be installed via luarocks:

luarocks install luautf8 --lua-version=V --local
luarocks install bigint --lua-version=V --local LD='clang -lstdc++'
luarocks install luafilesystem --lua-version=V --local
luarocks install vstruct --lua-version=V --local
luarocks install inspect --lua-version=V --local

Lua 5.1 only:

luarocks install bit32 --lua-version=5.1 --local

where V is your lua version (5.1, 5.2, 5.3).


Before you proceed, fill in the LuaVersion and LuaExe environment variables with a desired Lua version and a name of the executable file for that version.

Build, test and install:

make all && make install

Idris 2 REPL preconfigured with lua codegen will be available under the name idris2-lua located in the same folder as your idris2 executable.

Status

  • The project aims to keep performance reasonable, Lua has many limitations, concerning local variables and nested structures like if-then-else statements, leading to design choices that may decrease performance and limit what the Lua runtime can do to optimize execution. Suggestions are welcome !

  • Major chez tests taken from the official repository under tests/chez run successfully, those which don't are primary FFI or BitXX tests.

Structure and How-Tos

  • Backend needs to know what version of Lua you target as there are incompatibilities:

    Define a global varible LuaVersion with a value: 5.1, 5.2, 5.3

  • If you want to run generated code within the REPL, define LuaExe with the name of the Lua executable (which should be in PATH) of the target version. If the variable is undefined, the backend will default to lua.

Good to know

  • Lua 5.1 and Lua 5.2 do not support 64 bit integers ! Best precision you can get is 52 bits. Also, if you use Buffers maximum precision is 48 bits, disregarding the Lua version ! This is planned to be fixed moving to native buffers.
  • Bits8, Bits16, Bits32, Bits64 are not yet implemented

idris2-lua's People

Contributors

russoul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

a8e5

idris2-lua's Issues

Error: Module Libraries.Data.Bool.Extra not found

Trying to install with Idris 2, v0.3.0, and I get this:

$ make all && make install
idris2 --build idris2-lua.ipkg
1/4: Building LuaCommon (src\LuaCommon.idr)
2/4: Building OrderDefs (src\OrderDefs.idr)
3/4: Building LuaAst (src\LuaAst.idr)
Error: Module Libraries.Data.Bool.Extra not
found

LuaGen:9:1--9:33
 5 |
 6 | import Core.Context
 7 | import Core.Directory
 8 |
 9 | import Libraries.Data.Bool.Extra
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

make: *** [Makefile:36: build/exec/idris2-lua] Error 1

Is Idris2-Lua compatible with v0.3.0?

Readme instructions for installing `bigint`

This is more of a note than an "issue" as such.

I needed to specify CFLAGS='--stdlib=libc++' when installing bigint to silence a warning:

clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]

I'm not sure if this is due to some quirk of my own Mac Brew setup, or if it's common to some or all other setups.

Readme and requirements clarification

Hey, you've done a great job! I think at least two things should be added to the readme.

What is required/expected lua version? I've checked that your codegen does not work with 5.1 (accidentially installed on my machine).

Also, I think that it should be in the readme that not only Idris 2 should be installed but that Idris2 API library (i.e. those named idris2) should be installed also (e.g. using make install-api of Idris 2).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.