Installing the Toolchain with GHCup
The modern, recommended way to install a Haskell toolchain is GHCup, a cross-platform installer script that manages GHC (the compiler), Cabal (the base package manager and build tool), Stack (a higher-level project and dependency manager), and HLS (the Haskell Language Server for editor tooling) as independently switchable versions. Running curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh on Linux or macOS downloads GHCup and walks you through installing a default GHC version, after which ghc --version and ghci --version should both report the installed release.
Cricket analogy: GHCup managing multiple GHC versions side by side is like an international squad maintaining separate red-ball and white-ball setups -- you switch tools (ghcup set ghc 9.6.4) the way a captain switches formats without discarding either setup.
# Install GHCup (Linux / macOS)
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
# Verify the toolchain
ghc --version
ghci --version
cabal --version
stack --version
# List and switch installed GHC versions
ghcup list
ghcup set ghc 9.6.4
On Windows, GHCup ships a PowerShell installer instead of the curl-based shell script; run it from an elevated PowerShell prompt and it will configure MSYS2 automatically for native library dependencies.
Stack and Reproducible Builds
Stack is a build tool built on top of Cabal and GHCup that adds reproducible builds through curated package snapshots called resolvers -- for example lts-22.13 pins an exact, mutually-compatible set of package versions from Stackage so that stack build produces the same result on every machine, unlike plain Cabal, which resolves dependencies against the ever-changing Hackage index unless a cabal.project.freeze file is used. stack new my-project scaffolds a new project directory with a .cabal file, a stack.yaml resolver file, and a src/Main.hs entry point ready to build with stack build and run with stack run.
Cricket analogy: Stack's resolver pinning every package to a known-compatible version is like an ICC tournament using a fixed, pre-approved kit list so every team's equipment is guaranteed compatible with the match regulations, unlike a friendly match with no such guarantee.
# Scaffold a new Stack project
stack new my-project
cd my-project
# Build and run it
stack build
stack run
The Daily Workflow: ghci, stack build, stack ghci
After installation, three commands form the daily workflow: ghci launches an interactive REPL for quickly evaluating expressions and loading modules with :load Main.hs or :l Main.hs; stack build compiles a project according to its stack.yaml and .cabal files; and stack ghci opens a REPL with the project's own dependencies already in scope, which is what you want when experimenting with functions from a library your project depends on rather than plain GHCi's bare environment.
Cricket analogy: Using ghci for a quick one-off expression versus stack ghci for full project context is like a batter taking a few throwdowns in the nets versus playing an actual practice match with the full XI and match conditions loaded.
Don't mix a globally-installed cabal install package set with a Stack project's resolver-pinned dependencies -- loading mismatched versions of the same library in the same session is a common source of confusing 'no instance for' or symbol-clash errors for beginners.
- GHCup is the recommended cross-platform installer for GHC, Cabal, Stack, and HLS.
ghc --versionandghci --versionconfirm a working compiler and REPL after install.- Stack adds reproducible builds via curated Stackage resolvers such as
lts-22.13. stack new my-projectscaffolds a.cabalfile,stack.yaml, andsrc/Main.hs.stack buildcompiles a project;stack runbuilds and executes it.stack ghciopens a REPL with the project's own dependencies already in scope.- Avoid mixing global Cabal-installed packages with Stack's pinned resolver dependencies.
Practice what you learned
1. What is the recommended tool for installing GHC, Cabal, Stack, and HLS?
2. What does a Stack resolver like `lts-22.13` provide?
3. Which command scaffolds a brand-new Stack project?
4. Why would you use `stack ghci` instead of plain `ghci` when working on a project?
5. What command builds a Stack project according to its stack.yaml and .cabal files?
Was this page helpful?
You May Also Like
What Is Haskell?
An introduction to Haskell as a purely functional, statically typed, lazily evaluated language, and why those properties matter in practice.
Your First Haskell Program
Writing, compiling, and running a first Haskell program, from a one-line Hello World to a small interactive do-notation example.
Cabal and Package Management
Learn how Cabal defines, builds, and resolves dependencies for Haskell projects, and how it works alongside Stack and Hackage.
Values and Types in Haskell
How Haskell's static type system, primitive types, immutable value bindings, and type inference work together, illustrated with GHCi examples.
Related Reading
Related Study Notes in Programming
Browse all study notesApache Spark Study Notes
Programming · 30 topics
ProgrammingApache Flink Study Notes
Programming · 30 topics
ProgrammingHadoop Study Notes
Programming · 30 topics
ProgrammingSnowflake Study Notes
Programming · 30 topics
ProgrammingApache Airflow Study Notes
Programming · 30 topics
Programmingdbt (Data Build Tool) Study Notes
Programming · 30 topics