Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

8. Input and Output > Hello, World!

Hello, World!

Until now, we’ve always loaded our functions into GHCi to test them. We’ve also explored the standard library functions in that way. Now we’re finally going to write our first real Haskell program! Yay! And sure enough, we’re going to do the good old Hello, world! schtick.

image with no caption

For starters, punch the following into your favorite text editor:

main = putStrLn "hello, world"

We just defined main, and in it we call a function called putStrLn with the parameter "hello, world". Save that file as helloworld.hs.

We’re going to do something we’ve never done before: compile our program, so that we get an executable file that we can run! Open your terminal, navigate to the directory where helloworld.hs is located, and enter the following:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint