Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell Hello world, eclipse IDE

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?

like image 242
Scott Weinstein Avatar asked Aug 03 '09 04:08

Scott Weinstein


3 Answers

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.

like image 70
Tom Lokhorst Avatar answered Nov 16 '22 14:11

Tom Lokhorst


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.

like image 40
Peter Avatar answered Nov 16 '22 14:11

Peter


Never used eclipse but what you see is ghci, GHCi is GHC's interactive environment. Your module was loaded successfully in ghci, you can type main in ghci to run the function main of your program, actually you can call any function of your program that way.

like image 4
hiena Avatar answered Nov 16 '22 12:11

hiena