mmhelloworld

main = println "Hello World!"

Idris 2 Initial Release 0.2.1 for the JVM

There is now an initial version for Idris 2 - 0.2.1 for the JVM. This is compiled from Idris 2 JVM bootstrap version.

Changes:

  • Compile initial Idris 2 compiler (0.2.1) with Idris 2 JVM bootstrap version targeting Java 8 bytecode
  • Add JVM backend
  • Support primitives 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:

To compile and run:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Main

data Tree a = Leaf
            | Node (Tree a) a (Tree a)

inorder : Tree a -> List a
inorder Leaf = []
inorder (Node left a right) = inorder left ++ [a] ++ inorder right

tree : Tree String
tree = Node
        (Node
          (Node Leaf "3" Leaf)
          "+"
          (Node Leaf "7" Leaf))
        "/"
        (Node Leaf "2" Leaf)

main : IO ()
main = printLn $ inorder tree
1
2
3
4
$ idris2 Main.idr -o main

$ java -jar build/exec/main_app/main.jar
["3", "+", "7", "/", "2"]

Comments