Haskell Hello World Page
/*********************************************** * Image Thumbnail Viewer Script- © Dynamic Drive (www.dynamicdrive.com) * This notice must stay intact for legal use. * Visit http://www.dynamicdrive.com/ for full source code ***********************************************/
From Wikipedia, the free encyclopedia, the definition of functional
programming paradigm is:
In computer science, functional programming is a programming paradigm
that treats computation as the evaluation of mathematical functions and
avoids state and mutable data. It emphasizes the application of
functions, in contrast with the imperative programming style that
emphasizes changes in state.[1]
First lets start with what you can do like in 2 minutes … personally
that gives me more satisfaction than reading a page of theory and not
seeing it at work.
-
Download and install GHC from :
GHC -
Run GHC and type this : putStrLn “Hello, world!” (Note: Pay strict
attention to putStrLn casing, its same as in Java but still.
Voila! your done; but I don’t know i feel bad about working in Consoles, makes me remember those C mixed with Assembly days … :), so here we go! use the below stuff if you are interested in doing stuff in Eclipse.
Prerequisites:
-
You need a
Java 5.0 compliant virtual machine (JDK or JRE) installed on
your system. (For Linux, Solaris and Windows systems you can find one
at
http://java.sun.com/). -
You need
Eclipse 3.1.x. If you need an older version of Eclipse, you
should stick to version 0.6 of the Haskell plugins. If you don’t have
Eclipse, download it from
http://eclipse.org/downloads/. Look for the platform runtime
binaries, if you don’t want to download the entire SDK. (The platform
runtime contains the basic Eclipse IDE without Java and Plugin
development tools.) -
You need a
GHC installed on your system. See above.
Download and install
: Now for those of you who are working with eclipse, you
use
eclipse for haskell programming. Here’s how :
- Go to Help > Software and Updates > Find and Install >
-
Use new Remote Site, type a Name for remote site, use Haskell,
Haskell
Fp.
Now that you have Haskell installed on your eclipse, following images :
-
Step 1:
New Project -
Step 2:
Enter project Name -
Step 3:
Create a New haskell Module -
Step 4:
Step 4 -
Step 5:
Compile using CONTROL + F11 (your plain eclipse compile and run),
this would create a “theResult.exe”, find the path of it, and run
this exe file on command prompt and there you go, see for yourself:
finally the output
Over the course of time, (Expect to see more pages added to Haskell Series above) I will talk about Haskell type system and other things.
Regards Vyas, Anirudh
PS: Can someone tell me how to improve those Ugly images alignment?!