Frege – Haskell for the JVM
29 June 2016, by Chris Arnott
In the programming world we like an interesting challenge, and one of the more challenging concepts in our profession is that of functional languages. With more functional languages gaining lots of traction (Softwire have done several projects in python and Scala, as well as other functional oriented languages) there are some interesting projects going on.
Frege is a Haskell compiler for the JVM. It allows compiling down Haskell code into Java code that can be run on the jvm. This allows it to be called from any other Java projects.
This isn’t a new concept. Scala, which is a language that mixes Object Oriented and Functional paradigms is based purely on the JVM, and there are many languages that can be compiled down to Java (see the wikipedia page for a list).
So why would you want to do this? Some concepts are much easier to represent in functional terms (see monads) and these can result in much more succinct and readable code. For this reason it makes sense to have the ability to access functional code from your java code. Frege gives developers that opportunity.
So why not try it out? I would be surprised if using Frege will revolutionise your workflow, but it could well help out next time you need to use some functional patterns in the java code you are writing.