Setting Up Your Environment
Prerequisites: Installing Haskell
Editor
Visual Studio Code with the Haskell extension is the most common setup. The extension uses the Haskell Language Server (HLS) — which GHCup can install for you — to show type errors as you type, the type of anything you hover over, autocompletion, and HLint suggestions. Neovim, Emacs, and other editors talk to the same language server.
Hovering to see types is especially valuable in Haskell: reading types is how you understand code.
The interactive interpreter
Run ghci to get an interactive prompt (a REPL):
$ ghci
GHCi, version 9.14.1: https://www.haskell.org/ghc/ :? for help
ghci> 1 + 2
3
ghci> "Haskell" ++ " rocks"
"Haskell rocks"
ghci> :q
Leaving GHCi.
Type an expression to see its value. Commands start with a colon: :q
quits, :? lists all commands. The next lessons use GHCi a lot.
Running files
runghc hello.hs # interpret a file and run its main
ghc hello.hs # compile to an executable (hello.exe on Windows)
ghci hello.hs # load a file into the REPL
For a single file, runghc is the quickest. Real projects use cabal
(Level 2), which manages dependencies and builds for you.
Formatting and linting
- Ormolu or Fourmolu formats code consistently.
- HLint suggests simpler ways to write things — for example, replacing
\x -> f xwith justf.