This document shows how you would create and run the 'Hello World' application in Eclipse with Haskell support. It also explains some of the main user interface elements in Eclipse. The focus is on helping developers who are not familiar with Eclipse to quickly get started with it as an IDE that supports Haskell development.
Note: This is work in progress, which means that some of the features described here may not yet be in place. Have a look at the feature plan for information about what is already contained and what is planned.
Open the Haskell Perspective
Eclipse makes use of a concept called Perspectives. Everything in the workspace is seen from such a Perspective. When you start Eclipse for the first time, the most basic of all Perspectives is open: the Resource Perspective, which handles just some basic file management and text editing. By openening the Haskell perspective, you activate everything that is Haskell-aware.
Select from the menu: Window > Open Perspective > Haskell. (You can also open the Haskell Perspective from a link on the Welcome page.)
Seen from the Haskell Perspective, a file is not just a file, but (if it has the correct extension) a Haskell source file, which means that you can open it with the Haskell source editor, you can compile it and run it with a Haskell interpreter (like HUGS) or as (e.g. with GHC) compiled and linked executable. The Perspective contains also some Views, which provide Haskell-specific information about the file which is currently opened in the editor (Outline View) or about the last build process (Compiler Output View).
You can switch and close Perspectives at any time from the vertical toolbar at the left of the workbench. If you have closed a Perspective or a View, you can re-open it from the menu Window > Open Perspective or Show View.
The workspace is organized into Projects (roughly: directories within the workspace directory).
Create a new project by selecting File > New > Project from the menu, expanding the Functional programming icon, then choosing Haskell Project. Specify a project name and hit OK.
A Haskell project has some properties:
When the project has been created, you will see the respective folders, which are created by the New Project wizard. You can configure these settings on the Preference Page for that wizard.
Add source files to the project source folder.
Files can be created either from the menu (File > New), or from the context menu you get when you right-click the project in the Navigator View).
For the 'Hello world' program, create a new file named
Main.hs.
If you give the files a Haskell-specific extension (like .hs
or .lhs (for literate Haskell), you can open the files with
the Haskell source code editor from the Navigator View.
Right-click the file and choose Open with >Haskell editor. Type some code.
You can configure the editor in the main Preferences Dialog: Select Window > Preferences from the menu and choose the Functional Programming section.
Enter the code for your 'Hello world', e.g.
| |
Save. This will trigger the auto building, and you will see compiler errors (if there were errors in the build) in the Problems View. If no errors have occured, the compiled object files and the linked executable should be in their respective folders. Auto building works incrementally, that is, only changed resources are built when you save again.
You can launch the compiled executable of your Haskell programs from within the IDE.
Running a program creates a new Launch configuration for that program. You can re-run a lauch configuration from the Run menu. Clicking the Run-icon re-launches always the last launched configuration.
If you choose Run ... from the menu, you get a dialog where you can edit launch configurations. For example, you may want to add parameters to the program launch.
Console input and output are handled by the Console View (at the bottom left of the workbench). You should see the 'Hello world' output appear there, and if your program takes console input, the Console View is where you can type in while developing.