-
Notifications
You must be signed in to change notification settings - Fork 4
0007: Email Tutorials Haskell For Beginners ‐ Installing Haskell on Windows 10
- 7.1. Goal: Setting Up Your Haskell Environment on Windows
- 7.2. Installing Haskell and GHC Using GHCup
- 7.3. Installing Optional Tools: HLS and Stack
- 7.4. Verifying Your Installation from PowerShell
- 7.5. Writing Your First Haskell Program (
hello.hs) - 7.6. Compiling and Running with
ghc - 7.7. Running Code Interactively with
ghci - 7.8. When to Prefer
ghciover Compiling - 7.9. Glossary of Terms for This Lesson
In this lesson, you’ll go from having no Haskell setup on Windows to having a full working environment. This includes the GHC compiler, interactive GHCi, and related build tools. By the end, you’ll have compiled and run your first “Hello, World!” program and learned how to experiment quickly using ghci. The focus is specifically on Windows 10, using official tooling recommended by the Haskell community.
The recommended way to install Haskell on Windows is to use GHCup, a tool that manages Haskell installations for you.
- Open a web browser and go to:
https://www.haskell.org/ghcup. - On that page, you’ll see a code snippet in a box for Windows. Click the button that copies this command to your clipboard.
- Open a PowerShell window (normal user is fine; you do not need administrator privileges).
- Right-click in the PowerShell window to paste the command, then press Enter to run it.
At first, it may look like nothing is happening. The video mentions that it took about 20 seconds before any output appeared, so a short period of silence is normal. Once things start, you’ll see text explaining what can be installed and where.
The GHCup install script explains that it can install several tools:
- GHC – the Glasgow Haskell Compiler.
- GHCi – the interactive version of GHC.
- Cabal – a build tool and package manager.
- Haskell Language Server (HLS) – for editor/IDE integration.
- Stack – another Haskell build tool and package manager.
In this setup, you:
- Accept the default installation paths on the
C:drive by pressing Enter. - Accept the default location for cabal.
- Choose to install the optional programs: Haskell Language Server and stack.
This gives you a complete Haskell platform on your system, suitable for building full applications and using feature-rich editors later. The installer may take a while—on the demo virtual machine it took around 25 minutes—but once it finishes, it will print a message indicating that everything is done.
After installation completes:
- Close any existing PowerShell windows used during install.
- Open a new PowerShell window, so your environment picks up the new PATH settings.
Now you can verify that the tools are available by asking each program what version it is running, using the --version flag. For example:
-
ghc --version– confirms the Glasgow Haskell Compiler is installed. -
ghci --version– confirms the interactive GHCi is installed. -
cabal --version– confirms the cabal build tool is available. -
stack --version– confirms stack is installed.
Seeing version numbers printed means the commands are recognized and in your PATH, so your environment is ready.
Next, you write and run a simple Haskell program.
-
In Windows, create a new file named
hello.hs. -
Make sure you can see file extensions so you don’t accidentally create
hello.hs.txt. The file must end exactly in.hs. -
Open
hello.hsin a text editor. The video uses Notepad to keep things simple. -
Add the following code exactly:
main = putStrLn "hello world"
Note the capital letters in
putStrLn(SandLare uppercase), and the"hello world"string is enclosed in double quotes. -
Save the file and close the editor.
This program defines a main function that prints "hello world" to the screen when executed.
Now you compile and run hello.hs using GHC:
-
Open a PowerShell window in the directory where
hello.hsis saved. -
Run the command:
ghc -o hello hello.hs
- The first
helloafter-ois the base name for the output files. -
hello.hsis the source file you want to compile.
- The first
-
After compilation, list the files in the directory again. You should see:
-
hello.hs– your source code. -
hello.o– an object file produced during compilation. -
hello.hi– an interface file produced by GHC. -
hello.exe– the final executable program.
-
-
Run
hello.exe(e.g.,.\hellofrom PowerShell). It should print:hello world
That’s your first compiled Haskell program running on Windows.
Compiling and running is powerful, but when you’re learning, constantly recompiling for every tiny change can feel slow. This is where ghci comes in. It is an interactive Haskell environment (a REPL) where you can type code and see results immediately.
-
In PowerShell, run:
ghci
-
At the
ghciprompt, you can enter any valid Haskell expression or definition. For example, you can redefine:main = putStrLn "hello world"
-
After defining
main, type:main
and press Enter. You’ll see the same
"hello world"output printed in the terminal, just like with the compiled program. -
You can also try simple expressions like:
2 + 2
and GHCi will immediately evaluate and show the result.
-
To leave
ghci, type::quitand press Enter.
The lesson emphasizes that ghci is usually faster and more convenient when you are:
- Experimenting with snippets of code.
- Trying out small functions or expressions.
- Learning new concepts and testing ideas interactively.
You can compile programs every time with ghc, but for most learning tasks, ghci saves you time and effort by avoiding full compilation on every small change. You’ll mostly use ghci throughout the course, while knowing that ghc is there when you want to build standalone executables.
-
GHC (Glasgow Haskell Compiler) The standard Haskell compiler. It translates
.hssource files into object files and executables such ashello.exe. -
GHCi The interactive version of GHC. It provides a prompt where you can type Haskell code, define functions, and evaluate expressions immediately.
-
GHCup An installer and version manager for Haskell tools. On Windows, it automates downloading and installing GHC, GHCi, cabal, stack, and related components.
-
Cabal A Haskell build tool and package manager. It helps manage project dependencies and building more complex Haskell projects.
-
Stack Another Haskell build tool and project manager, often used for managing reproducible builds and larger projects.
-
Haskell Language Server (HLS) A background service that integrates with editors/IDEs to provide features like type information, error highlighting, and auto-completion for Haskell code.
-
PowerShell The Windows command-line shell used in this lesson to run installation commands, compiler commands, and executables.
-
.hsfile A text file containing Haskell source code. By convention, all Haskell modules and scripts are stored in files ending with.hs. -
Executable (
.exe) The compiled binary produced by GHC on Windows, such ashello.exe, which you can run directly to execute your Haskell program. -
REPL (Read–Eval–Print Loop) A style of interactive environment like
ghciwhere you type expressions, they are evaluated, and the results are printed immediately.
Bernard Sibanda is a global Technology Entrepreneur, Web3 and Software Consultant with a deep focus on Cardano Blockchain, Midnight and Community building.
Key Positions:
- Founder, CTO, Developer Advocate cohort #1, Fullstake Developer, Cardano Ambassador, Catalyst Project Manager, DREP-WIMS:
- Co-founder of ABL Tech and Cardano Africa Live
- EBU-certified Plutus Pioneer (Plutus/Haskell)
- Cohort #1 Plutus Pioneer Developer
- Catalyst Community Reviewer & Funded Projects Manager
-
DRep for WIMS-Cardano (ID:
drep1yguj8zu48n99pv70yl6ckzt9hdgjy8yjnlqs2uyzcpafnjgu4vkul) - Intersect Developer Advocate
- Intersect Committe Member 2025-2026
- Cardano Marketer,Promoter and blogger
- Cardano Open Source Contributor
- Cardano communities and events organizer and builder
- Cardano Ambassador for South Africa
Official links:
- Stablecoins Dex
- Coxygen Global Universities
- WIMS Cardano Global
- Cardano Africa Live
- WIMS Cardano Videos
- Cardano Smart Contract Videos
- Fullstack IT Consulting
Social links: