August 31, 2026

Haskell for Hobos-- Hello

It is traditional, almost mandatory, to begin study of a new computer language with the "hello world" example. Here it is:
#!/usr/bin/runghc
main = putStrLn "Hello World!"
This is really just one line of Haskell, if you ignore the "shebang" line that tells the system to use "runghc" to cope with the file. On my system, this is the file "hello.hs" and I run it via:
./hello.hs
When you tell haskell to run a program, it looks for a function called "main" and tries to evaluate it. If there is no main, it gets upset.

There is more going on here than meets the eye. Rather than explain things now, we will refer back to this when we get to the concepts themselves.

Many tutorials side-step this and have you run "ghci" which is an interactive Haskell tool. I have never been entirely happy with this because there are some special rules that make some things different when used from the ghci prompt. If you go that route, you will have to unlearn certain things later.

Not only that, but if I want to work with more than a line or two of haskell, I want to use a text editor to put it into a file. Suit yourself

Compiling Haskell

Using haskell the way I do with runghc makes haskell act more or less as an interpreter (like python or perl). But you can compile haskell, and compiled haskell code can be pretty good, or so I am told. We won't do much (or any) of that in this series, but for the record, here is what you do:
ghc hello1.hs
./hello1

Installing Haskell

You may be wondering about "GHC". This stands for "Glasgow Haskell Compiler" which seems to be the most commonly used and available form of Haskell.

I don't talk about how to install Haskell. You will have to do some searching and learn how to install it on your system. I use Haskell on my Fedora linux system (currently running Fedora 44). I found "ghc" in the standard Fedora package collection and installed it using the standard fedora package manager (dnf). At this point I am using "The Glorious Glasgow Haskell Compilation System, version 9.10.3".

Heaven only knows what you will need to do on your system.
You might start with this link:

This document describes some hair splitting issues with GHC as compared to what is described in the Haskell documents (such that they are). You are unlikely to care about any of this:


Have any comments? Questions? Drop me a line!

Tom's software pages / tom@mmto.org