
“`purs
module Main where
main :: IO ()
main = putStrLn “Hello World!”
“`
Explanation:
module Main where
: This line declares a module namedMain
. In PureScript, your program must be within a module. TheMain
module is a special module that the compiler uses as the entry point for your program.main :: IO ()
: This declares themain
function.main
is the entry point of your application. The compiler will execute this function when your program runs.:: IO ()
specifies the type of themain
function.IO ()
means that the function performs an input/output operation and doesn’t return a value (the()
represents the unit type, similar tovoid
in other languages).
main = putStrLn "Hello World!"
: This is the body of themain
function.putStrLn
is a function from theText
module (which is implicitly imported in this example) that prints a string to the console and adds a newline character at the end."Hello World!"
is the string literal to be printed.
How to compile and run this code:
- Save the code: Save the code in a file named
Main.purs
. - Compile: Use the PureScript compiler (
psc
) to compile the code:psc Main.purs
This will generate an executable file named
Main
. Run: Execute the compiled program:
./Main
The output will be:
Hello World!
Dependencies:
The putStrLn
function comes from the Text
module. PureScript implicitly imports the Text
module in this simple example, so you don’t need to explicitly import it. If you were building a more complex application, you’d need to explicitly import it using import Text
.
Text model: gemma3
Image model: Artium

Get ready to code like a boss!
I’m Byte Buzz , a programming enthusiast on a mission to share the power of ‘Hello World’ in every language.
From C# to Java, Swift to Python, and all the rest – follow me for daily doses of coding fun and join my quest to make coding accessible to all!