Skip to content

Using Frege in Intellij IDEA

Dierk edited this page Oct 25, 2014 · 17 revisions

under construction

For those who prefer working in an IDE, there is special Frege support for eclipse. However, Intellij IDEA can also be set up to compile and run Frege code smoothly even though the support is much less advanced. If you would like to see better Frege support in IDEA, please upvote the Frege issue.

This page describes how you can

  • edit Frege code with basic syntax highlighting and general editing support (commenting, search/replace, hippy-completion)
  • automatically compile Frege code whenever you change a .fr file
  • run Frege code
  • run QuickCheck
  • start the Frege REPL internally with your code on the classpath.

Prerequites

Make sure you have recent version of IntellijIDEA. Any 13.x version or higher should be fine. The free community edition is totally sufficient. Some basic knowledge of this IDE is assumed below.

Make sure you have a Java 1.7 SDK installed.

Install the following plugins from the JetBrains plugin site if you don't have them yet:

  • the Haskell plugin
  • the File Watcher plugin

Jump Start

Register Frege files as having the Haskell file type such that the Haskell plugin will do the syntax highlighting. Go to Preferences -> Editor -> File Types and add *.fr to the list of Haskell file extensions. FrAsHaskellFileType

Next you need the Frege jar (and the REPL jars if you want to use it) as a library in IDEA. I recommend to create a "global" library such that you can share it between many projects. Note that you can point directly to your download locations of the jars, but you can also use IDEA's maven support to create libraries from maven (just select "maven", type "frege" when asked, and select your version of choice).

Here is the naming that I have chosen: FregeLibsInIdea

Head over to https://github.com/Dierk/HelloFrege and download the project. (You can use your preferred method of either cloning, forking, or downloading as zip).

You should now be able to open that project in IDEA. Most likely some of your local names are different from what the project expects, e.g. the name of the Java SDK and the names of the Frege and FregeRepl libraries. You need to adapt this in the project structure / module settings.

That being done, you can edit the Frege code with automatic compile, run all quickcheck tests and work with the REPL.

Rename the application, adapt the git settings, and add off you go!

Under the hood

Here are the considerations behind the structure of the HelloFrege project.

We are working from two different modules:

  • the source module is holding the actual Frege code
  • the target module holds the *.class and *.java Files that Frege creates.

A file watcher is set on the source module to kick off the the compiler whenever it picks up a change.

Running code, running tests, and starting the REPL is all done with the classpath of the target module.

Clone this wiki locally