Question: I would like to understand the basics of how to write and execute Haskell program on Linux OS. Can you explain it with a simple example?
Answer: In this article, let us review very quickly how to write a basic Hello World Haskell program and execute haskell program on Linux or Unix OS.
Also, refer to Haskell article on wikipedia to learn about this programming language.
1. Write a Hello World Haskell Program
Create the helloworld program using the Vim editor as shown below.
$ vim helloworld.hs -- hello world example main = putStrLn "Hello, World!"
Note: Comment in Haskell starts with –.
2. Make sure Haskell Compiler is installed on your system
Make sure Haskell compiler is installed on your system as shown below.
$ whereis ghc ghc: /usr/bin/ghc /usr/share/man/man1/ghc.1.gz
Installing haskell ( ghc ) compiler
If you don’t have haskell compiler, install it as shown below.
$ sudo apt-get install ghc6
3. Compile the haskell program
Compile the HelloWorld which will create the HelloWorld executable.
Compile and get a.out.
$ ghc helloworld.hs
Compile and get executable in desired name with -o option.
$ ghc -o helloworld helloworld.hs
4. Execute the haskell Program
Execute by mentioning the program name.
$./a.out Hello, World! $./helloworld Hello, World!
Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.Get the Linux Sysadmin Course Now!
If you enjoyed this article, you might also like..
|
|
|
|






My name is Ramesh Natarajan. I will be posting instruction guides, how-to, troubleshooting tips and tricks on Linux, database, hardware, security and web. My focus is to write articles that will either teach you or help you resolve a problem. Read more about
{ 2 comments… read them below or add one }
Cripes!!
-rwxrwxr-x 1 chris chris 500103 19-Mar-2010 17:02:14 a.out
Thank you! It worked for me!