Skip to content
Cary Robbins edited this page Jul 4, 2015 · 17 revisions

Dependencies

  • IntelliJ IDEA >= 13.1.5 - See the Dependencies section of the wiki to understand why.
  • Cabal >= 1.18 - While the IDE will function without Cabal 1.18, you will not be able to use run configurations without it.

Installing the plugin

Warning: You cannot use multiple Haskell plugins at the same time. If you have installed a Haskell language plugin for IntelliJ be sure to uninstall it before installing this one.

You can install the plugin using the JetBrains plugin repository -

  • Preferences > Plugins > Browse repositories > HaskForce

Alternatively, you can download the latest zip archive from the releases page and install it from -

  • Preferences > Plugins > Install plugin from disk.

Note that pre-releases are non-production builds. If you encounter any issues please report them in our issues tracker.

Creating a new project

  1. Choose New Project, select the Haskell option, then click Next.
  2. Select your GHC SDK or create a new one by clicking Configure. HaskForce will attempt to find your GHC installation automatically, but if it does not, point to the installation directory, which should have a bin, lib, and/or share directory.
  3. Configure the paths to your compiler tools. You can use Set as default so that HaskForce will remember your preferences for future projects.
  4. Configure the Cabal package. HaskForce will use Cabal to initialize the package for you, creating a Cabal file. If you'd prefer to omit this, simply uncheck Initialize Cabal package at the top of the dialog.
  5. Enter the project name and location and click Finish.

Creating a project from existing sources

  1. Create a new project using the steps from above and set the project location to the root of your existing project. Be sure to uncheck Initialize Cabal package if your project already has a Cabal file.
  2. Use Tools > Discover Cabal packages if you have any sub-projects. This will find existing Cabal files in your project and allow you to choose which ones you would like to import.

Creating Cabal packages

  1. Choose Tools > Add Cabal Package.
  2. Fill out the info for your new Cabal package.
  3. Upon clicking OK, HaskForce will initialize the Cabal package and create a Cabal file for you.

Configuring external tools

HaskForce can integrate with tools such as HLint, Stylish-Haskell and ghc-mod. Install the tools you wish to use:

cabal install hlint stylish-haskell ghc-mod

And then configure them from Project Preferences > Haskell Tools. The Auto Find button will attempt to find this executable for you. These are configured on a per-project basis. You can set the defaults for all projects using File > Other Settings > Default Settings.

Jump to Declaration

Currently you can jump to the declaration of any top-level function or data/newtype declaration. There are some complex cases where this doesn't work perfectly (e.g. complicated, nested imports) but for most use cases it works well. Jumping to local definitions is currently under development.

Autocompletion

HaskForce currently implements the following autocompletion features -

  • Reference completion - This completion is based on the references captured from the functions you have defined at the top-level, along with data/newtype declarations. This works mostly in conjunction with the Jump to Declaration section above.

  • GHC-Mod completion - This completion is more complex and gets you many more features. It does require you to set the paths to ghc-mod and optionally ghc-modi in your external tool settings. With GHC-Mod you get completion of -

    • Language extensions in LANGUAGE pragmas.
    • GHC flags in OPTIONS_GHC pragmas.
    • Module names in imports.
  • GHC-Modi completion - Same as above, except you get -

    • Name import completion - import Data.ByteString (rea readFile)
    • Qualified name completion - Data.ByteString.rea readFile
    • Prelude and imported name completion - foo = getL getLine

Note that retrieving completion information can be expensive so it is cached frequently. If you find that your completion cache needs to be updated, you can use Code > Haskell Completion Cache Reload. This is currently mapped to Ctrl+Shift+Space (Command+Shift+Space on OSX).

Error checking

Error checking is supplied with ghc-mod or ghc-modi. Error reporting turnaround time can be nearly 4 times faster with ghc-modi, so in most cases that is probably the best route. If IntelliJ is slow to respond at times, you may want to lower ghc-modi's Timeout in the Haskell Tools settings.

Please note that the ghc-mod tools currently have experimental support for multiple cabal components. If you have trouble with error checking in test suites, they can be Test suite components can be enabled simply by reconfiguring with tests enabled (this can be done via Preferences > Compiler > Haskell Compiler > Enable Tests and a rebuild or manually on the command line with cabal configure --enable-tests).

Building your application

In order to build your application you must be using a cabalized project. If so, you can use Build > Make Project.

To customize your build, navigate to Project Settings > Compiler > Haskell Compiler. From there you can set your preferences, such as disabling profiling, building in a sandbox, etc. You can set the defaults for all projects using File > Other Settings > Default Settings.

Running your application

HaskForce currently supports two run types: applications and test-suites. You can find these via the Edit Configurations menu. These are implemented using cabal run and cabal test, respectively. Use the Program Arguments parameter to specify alternative run configurations from the cabal file or other command line arguments.

Clone this wiki locally