Haskell · compiler · toolchain
GHC, the Glasgow Haskell Compiler: a practical 2026 guide
GHC — the Glasgow Haskell Compiler — is the standard compiler for Haskell, and effectively the engine under everything else in the ecosystem: Cabal, Stack and the Haskell Language Server all drive it. This guide explains what GHC is, how to install it cleanly in 2026, how to use GHCi, the compiler flags that actually matter, and how it fits with the build tools.
What GHC is
GHC compiles Haskell source into optimised native executables and provides GHCi, an interactive REPL for exploring code. It is a mature, heavily optimising compiler with a rich type system, and it ships the libraries (base and friends) your programs build on. Almost everything else in Haskell tooling is, at some level, a wrapper that invokes GHC with the right arguments.
Installing GHC (use GHCup)
Do not install GHC by hand. The clean, supported path is GHCup, which manages multiple GHC versions and lets you switch per project — see our GHCup install guide. In short:
ghcup install ghc recommended
ghcup set ghc 9.10.1
ghc --version The reason version management matters: real projects pin specific GHC versions, and GHCup makes having several installed painless.
GHCi: the interactive REPL
ghci # start the REPL
:load Main.hs # load a module (:l)
:type foldr # show a type (:t)
:reload # reload after edits (:r)
:quit # exit (:q) GHCi is where most Haskell development actually happens — load a module, test functions, inspect types, iterate.
The flags that matter
-O2— full optimisation for release builds (slower compile, faster runtime). Default is-O0.-Wall— enable the broad warning set; pair with-Werrorin CI to fail on warnings.-threaded— link the threaded runtime, needed for real concurrency/parallelism.-j— compile modules in parallel (see how Haskell builds use your cores).-rtsopts +RTS -N— let the program use multiple cores at runtime.
Compile directly with ghc -O2 Main.hs, but for anything beyond a single file you will drive GHC through a build tool.
How GHC fits with Cabal and Stack
You rarely call ghc by hand on a project. Cabal and Stack resolve dependencies and invoke GHC with the correct flags and package database for you — see the build-model background in Cabal 2.0 and the isolation history in Cabal sandboxes. The Haskell Language Server also runs GHC behind the scenes to give your editor types and diagnostics — see our HLS guide.
FAQ
Is GHC the only Haskell compiler? It is by far the dominant, standard one in 2026; other compilers exist but GHC is what virtually all tooling and libraries target.
How do I install GHC? Via GHCup — it manages versions and is the recommended installer on haskell.org.
What does -O2 do? It enables full optimisation: longer compile time, faster runtime. Use it for releases; the default -O0 is fine for fast iteration.
Do I need to call GHC directly? Rarely — Cabal or Stack invoke it for you on real projects. Direct ghc is handy for single-file scripts.