Lesson 1 of 16

Hello, World!

Your First Haskell Program

The entry point of every Haskell program is main, an IO action. To print a line of text, use putStrLn:

main :: IO ()
main = putStrLn "Hello, World!"

putStrLn prints a string followed by a newline. You can also use:

  • putStr — prints without a newline
  • print — prints any showable value (adds quotes around strings)
main = do
  putStrLn "Hello"   -- Hello
  putStr "no newline"
  print 42           -- 42

Comments

Single-line comments start with --:

-- This is a comment
main = putStrLn "code"  -- inline comment

Your Task

Print exactly Hello, World! using putStrLn.

Haskell loading...
Loading...
Click "Run" to execute your code.