Getting started with Frege

Getting started with Frege: Hello World and basic setup using Maven

I spent a couple of hours playing with Frege (Haskell on the JVM) and not much documentation tutorials seems available. I am trying to help writing this simple Hello World tutorial.

The code is available on Github:

Update: Frege has some very useful documentation at… where … represents the package, or module, name. For example, if one needs some reference for the package, one looks at

Frege Source Code

The code is very simple for our little hello world example. In this tutorial we focus mainly on configuring our environment.

We declare the name of module to be HelloWorld. It will affect the name of the Java class produced.

The third line defines the type signature of the main function, while the fourth lines define main as a call to putStrLn using an IO Monad. In practice, you have to do the operations which affect the real world (like reading from a file or writing to the screen) inside a do statement. The reason is that the compiler treat them differently from pure functions, which can be optimized in several ways (lazyness, memoization, etc.) while “realworld operations” cannot.

Writing the POM (Maven configuration file)

First let’s take a look to the whole file:

The dependencies contain frege, no surprises here:

We then use two plugins, to compile Frege code and Java code:

Finally we save the classpath used by Maven in a file (classpath.conf) by using  the maven-dependency-plugin

The classpath.conf file will be useful for running the application using the script.

Running the Application, the Script

To run the application we need the Frege jar and the classes generated from our Frege source code.

Compile and Running HelloWorld

After cloning the repository, you can simply run:

The result, should be something like:


Download the guide with 68 resources on Creating Programming Languages


Receive the guide to your inbox to read it on all your devices when you have time

Powered by ConvertKit
2 replies
  1. ingo says:

    Hi Frederico,

    in fact, we do have documentation for each and every module, type, type class and function.

    It is all below… where … represents the package, or module, name. For example, if one needs some reference for the package, one looks at

    The documentation is, of course, machine generated and pushed to the project, which is mapped to

    The important questions, of course, are: “What packages exists and what are they for?” and something like “I need to split a string. How to do that in frege?”

    Unfortunately, we don’t have a mechanism yet to answer those important question a newcomer is most likely to ask.

    If you have any ideas how to better this situation, your suggestiuons will be very welcome.

    Best Regards, Ingo

  2. Federico Tomassetti says:

    First of thank you for your comment Ingo, it is an honor to have you on my blog 🙂

    What I meant is that I could not find many tutorials or experience reports, that is why I thought it could be useful to have more Frege users/supporters write about it. So I get started. I am also working on a small example of how to call Java from Frege, with a description of the workflow and the configuration I use. I hope it can help other Frege newbies like me.

    I will add the links to the documentation at the top of the post.


Comments are closed.