Skip to content

Idris 2 JVM - v0.2.1-SNAPSHOT-20210720

Compare
Choose a tag to compare
@mmhelloworld mmhelloworld released this 20 Jul 07:01
· 1 commit to feature/release-0.2.1-jvm since this release

Changes

  • Compile initial Idris 2 compiler (0.2.1) with Idris 2 JVM bootstrap version targeting Java 8 bytecode
  • Add JVM backend
  • Support primtives such as system, IO, network, clock, buffer etc. for JVM backend
  • Eliminate tail recursion
  • Add debug information such as variable name, file name and line number in bytecode from Idris source
  • Compile Idris modules to Java classes at the bytecode level, Idris top level functions to static Java methods and Idris lambdas into Java lambdas with invokedynamic implementing Java Function interface.
  • Generate bytecode concurrently for modules
  • Generate classes with toString and property getters for Idris constructors
  • Infer types to avoid boxing and casting
  • Compile Idris list into a Java list
  • JVM foreign descriptors supporting static, instance, interface methods and constructor calls

To try it out:

  • Unzip idris2-jvm-0.2.1-SNAPSHOT-20210720.zip
  • Add bin directory to PATH variable
  • Copy .idris2 directory containing Idris 0.2.1 packages into your home directory

To compile and run:

module Main

%foreign "jvm:showInputDialog(java/lang/Object String),javax/swing/JOptionPane"
showInputDialog : String -> PrimIO String

main : IO ()
main = do
  name <- primIO $ showInputDialog "Name:"
  putStrLn $ "Hello " ++ name
$ idris2 Main.idr -o main
$ java -jar build/exec/main_app/main.jar

To run REPL:

$ idris2
     ____    __     _         ___                                           
    /  _/___/ /____(_)____   |__ \                                          
    / // __  / ___/ / ___/   __/ /     Version 0.2.1-97acec538
  _/ // /_/ / /  / (__  )   / __/      https://www.idris-lang.org           
 /___/\__,_/_/  /_/____/   /____/      Type :? for help                     

Welcome to Idris 2.  Enjoy yourself!
Main> "hello world"
"hello world"
Main> [1..10]  
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]