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.
-
mainFunction- In Haskell,
mainis the entry point of the program. - It executes when the program runs.
- In Haskell,
-
putStrLnFunctionputStrLnis 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.
putStrLnis used instead ofprint(common in imperative languages).- The
mainfunction 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!!!