2. Using Visual Haskell

2.1. Overview of features

The following features are provided in the Visual Studio editor when editing Haskell code:

  • Automatic checking of code as you type, and visual indication of parse errors, scoping errors and type errors.

  • Quick info: hovering the mouse over an identifier pops up an information box, including the type of the identifier.

  • A drop-down bar at the top of the editing window lists the top-level declarations in the module, and allows quick navigation to a declaration.

  • Name completion for identifiers in scope: press Ctrl+Space after a partial identifier to see the completions.

  • Go to declaration: right clicking on an identifier and selecting "Go to declaration" will jump the cursor to the declaration of the identifier. This works for locally-defined identifiers and those defined in another module of the project; it does not work for library functions currently.

The following features are provided by the project system for constructing Haskell projects:

Additionally, Visual Haskell is bundled with a large collection of documentation: the GHC manual, the hierarchical libraries reference, and other material all of which can be browsed within Visual Studio itself.

2.2. Getting Started

After installing Visual Haskell, start up Visual Studio as you would normally, and observe that on the splash screen where it lists the supported languages you should now see an icon for Visual Haskell (if you don't see this, something has gone wrong... please let us know).

Firstly, take a look at the bundled documentation. Go to Help->Contents, and you should see the “Visual Haskell Help Collection”, which contains a large collection of GHC and Haskell-related documentaiton, including this document.

To start using Visual Haskell right away, create a new project (File->New->Project...). Select one of the Haskell project types (Console Application or Library Package), and hit Ok. The project will be created for you, and an example module added: Main.hs for an application, or Module1.hs for a library.

You can now start adding code to Main.hs, or adding new modules. To add a new module, right-click on the src directory, and select Add->New Item. Visual Haskell supports hierarchical modules too: you can add new folders using the same Add menu to create new nodes in the hierarchy.

If you have any errors in your code, they will be underlined with a red squiggly line. Select the Tasks window (usually a tab near the bottom of the Visual Studio window) to see the error messages, and click on an error message to jump to it in the editor.

To build the program, hit Ctrl-Shift-B, or select one of the options from the Build menu.

2.3. Editing Haskell code

(ToDo: more detail here)

Your module must be plain Haskell (.hs) for the interactive features to fully work. If your module is pre-processed with CPP or Literate Haskell, then Visual Haskell will only check the module when it is saved; between saves the source will not be checked for errors and the type information will not be updated. If the source file is pre-processed with Happy or another pre-processor, then you may have to build the project before the type information will be updated (because the pre-processor is only run as part of the build process). Pre-processed source files work fine in a multi-module setting; you can have modules which depend on a pre-processed module and full interactive checking will still be available in those modules.

Because Visual Haskell is using GHC as a backend for its interactive editing features, it supports the full GHC language, including all extensions.

2.4. Using Projects

(ToDo: more detail here)



[1] This works as long as the Cabal package is using Cabal's simple build system; Cabal packages using their own build systems cannot be edited in Visual Haskell.