
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Haskell Program to Print Hello World
This tutorial will discuss writing a program to print Hello World! in Haskell Programming Language. The Computations in Haskell are done using mathematical functions. In this tutorial, We will discuss different ways to print Hello World! in Haskell.
Program to print Hello World! Using the "print" function.
Program to print Hello World! Using the "putStr" function.
Program to print Hello World! Using the "putStrLn" function.
Example
Program to print Hello World! Using the "print" function
main :: IO() main = do -- printing using the function print print ("Hello World!")
Output
Hello World!
In the above program, we printed the string "Hello World!" using the function print. Which takes a value(any datatype) as an argument and outputs it to the display console. The function print adds a new line ("
") character at the end of the output.
Example
Program to print Hello World! Using the "putStr" function
main :: IO() main = do -- printing using the function putStr putStr ("Hello World!")
Output
Hello World!
In the above program, we printed the string "Hello World!" using the function putStr. Which takes a String as an argument and outputs it to the display console. The putStr function print doesn't add a new line ("
") character at the end of the output.
Example
Program to print Hello World! Using the "putStrLn" function
main :: IO() main = do -- printing using the function putStrLn putStrLn ("Hello World!")
Output
Hello World!
In the above program, we printed the string "Hello World!" using the function putStr. Which takes a String as an argument and outputs it to the display console. The putStr function print adds a new line ("
") character at the end of the output.
Conclusion
In this tutorial, we discussed three different ways to implement a program to print Hello World in Haskell programming Language.