Skip to Content
Effective Haskell
book

Effective Haskell

by Rebecca Skinner
July 2023
Intermediate to advanced
670 pages
17h 13m
English
Pragmatic Bookshelf
Content preview from Effective Haskell

Writing Your First Haskell Program

Now that you have some experience evaluating expressions, it’s time to write your first complete Haskell program. We’ll start with an obligatory “Hello World” program by creating a new empty file named Main.hs in your Chapter1 directory.

Open Main.hs and copy this example:

 module​ ​Main​ ​where
 main = print ​"Hello, World!"

You’ll learn what each of these lines is doing as you work your way through the chapter, but for now let’s build the application and run your program.

From your command line you can compile your program by typing ghc Main. After the program is built you’ll have a new executable, Main, that you can run to see your message:

 user@host$ ​​ghc​​ ​​Main
 [1 of 1] Compiling Main ( Main.hs, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Grokking Functional Programming

Grokking Functional Programming

Michal Plachta
Grokking Algorithms

Grokking Algorithms

Aditya Bhargava
The Rust Programming Language, 2nd Edition

The Rust Programming Language, 2nd Edition

Steve Klabnik, Carol Nichols

Publisher Resources

ISBN: 9798888650400Errata Page