How to Install the Glasgow Haskell Compiler on Windows

In this tutorial, we will cover the various methods you can use to quickly configure the Haskell compiler on Windows system without using WSL.

How to Install the Glasgow Haskell Compiler on Windows

Haskell is a statically typed, purely functional programming language with type inference and lazy evaluation. It was developed to provide a higher degree of abstraction, and to incorporate recent advancements in the theory of computation and programming language design.

Haskell is a compiled programming language and hence, you need to install the compiler before you can write and execute Haskell code on your system.

Method 1 - Using Chocolatey

The first and most recommended method of install the GHC on Windows is using the Chocolatey package manager. If you do not have Chocolatey already installed, you can check the link below:

How to Install Chocolatey on Windows 11
In this tutorial, we will discuss how to quickly setup Chocolatey package manager on the latest version of Windows.

Once installed, run the the command below to install the GHC compiler:

choco install ghc

The command will perform the installation configurations and setup the Haskell compiler on your machine. Once successfully installed, run the command below to check the installed version.

ghc --version


The Glorious Glasgow Haskell Compilation System, version 9.6.2

In this case, we have version 9.6.2 installed on your machine.

Method 2 - Using Scoop

If you the scoop package manager installed on your machine, you can use it to install the GHC on your Windows machine.

The command is as shown:

scoop install haskell

This should download the Haskell compiler on your system. If you do not have the Haskell compiler installed, you can check the tutorial shown below:

How to Install Scoop on Windows
In this post, we will quickly go over how you can quickly install and configure Scoop package manager on Windows in easy steps.

Method 3 - Using GHCUP

ghcup is a CLI tool (Command Line Interface) which helps in managing the Haskell toolchain on your machine. It stands for "Glasgow Haskell Compiler UPdater" and it simplifies the process of installing the GHC (Glasgow Haskell Compiler) on your system.

To install GHCUp, run the script below in your PowerShell.

Set-ExecutionPolicy Bypass -Scope Process -Force;[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; try { Invoke-Command -ScriptBlock ([ScriptBlock]::Create((Invoke-WebRequest -UseBasicParsing))) -ArgumentList $true } catch { Write-Error $_ }

This should download and install the GHCUp toolchain on your machine.

You can then use it to install GHC as:

ghcup install ghc

This should should setup the compiler on your machine.

Haskell Hello World

As it is expected, once you've installed your compiler, you can build a simple Hello World program to test the compilation.

In your Windows filesystem, create a new file called hello.hs.

touch hello.hs

Once created, edit the hello.hs file and add the source code for the hello world program as shown:

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

Save and close the file.

Finally, open the command prompt/terminal navigate to the directory where you saved hello.hs, and run the command below to compile the program.

ghc -o hello hello.hs

This will produce an executable file named hello.exe

You can run as:


The code above should print the classic hello world program as shown:

Hello, World!


In this tutorial, we covered how you can use Chocolatey, Scoop, and GHCup to install the Glorious Glasgow Haskell Compiler on Windows.

Table of Contents
Great! Next, complete checkout for full access to GeekBits.
Welcome back! You've successfully signed in.
You've successfully subscribed to GeekBits.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.