Reputation: 19117
I'm having trouble getting "hello world" going with eclipseFP and Haskell.
I have the following code,
module Main where
main = putStr "Hello world!"
and when I compile it with
ghc.exe .\H1.hs -o hw.exe
it works fine, but under eclipseFP, when I run it I only see the following in the console window:
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Ok, modules loaded: Main.
Prelude Main>
What mistakes am I making?
Upvotes: 7
Views: 10137
Reputation: 13768
I haven't used EclipseFP in years, so bear that in mind.
What appears to be happening is that EclipseFP is loading GHCi in the console.
GHCi is an interactive Haskell shell, in which you can evaluate simple expressions. It also apparently loaded your module Main
, so you can use GHCi to call functions in your module.
If you type in :main
in the console, it will run you program and print "Hello world!", you could also call other functions you define in your program or standard Haskell functions.
However, what you may want to do is set EclipseFP to execute your program when you run, and I can't remember how to do that, probably somewhere in the "Run" menu.
Upvotes: 12
Reputation: 61
In the project explorer click on your project and then click the right mouse button and select Run As > Run Configurations > Run As Haskell Application
.
Upvotes: 6
Reputation: 41
In the eclipse run menu, select run configurations. Under the Automation tab enter main in the command to run on launch and it will do what you expect.
Upvotes: 4
Reputation: 11708
From what little I've seen of EclipseFP, it's merely an interface for GHCi. Which means, as far as I'm concerned, that there's no reason to use it, since you get all the bad of Eclipse (the bloat, the bottomless thirst for memory, the tortoise-on-sedatives speed), with absolutely none of the good (the indexing, the debugger, the management of your tool stack).
So what noob mistake did you make? You used Eclipse. It's OK -- an easy mistake to make. If you were learning Scala, Eclipse might have been the way to go. But with Haskell, you're better off running GHCi from the command line and using an editor like Notepad++ (which has decent syntax highlighting). For once, the command-line/editor combination is preferable not because it's macho, but because it's more useful.
If you absolutely must have an IDE, the pickings are few right now, but here's what I've found.
And of course, any found in the answer to this question.
I haven't used it, but Leksah seems to be the most feature-rich IDE to date. Personally, I'm sticking with Notepad++ and the command line.
Upvotes: 3