Haskell Program to print hello world
Program
main = putStrLn "Hello World!!!"
This simple Haskell program prints "Hello World!!!" to the console using the putStrLn
function.
-
main
Function- In Haskell,
main
is the entry point of the program. - It executes when the program runs.
- In Haskell,
-
putStrLn
FunctionputStrLn
is used to print a string followed by a newline."Hello World!!!"
is passed as an argument, so it gets printed to the screen.
Key Takeaways
- Haskell is a functional programming language, and everything revolves around expressions.
putStrLn
is used instead ofprint
(common in imperative languages).- The
main
function acts as the program's starting point.
Output
$ ghc -o hello-world hello-world.hs
[1 of 1] Compiling Main ( hello-world.hs, hello-world.o )
Linking hello-world ...
$ ./hello-world
Hello World!!!