Chapter 4. Using GHC

Table of Contents
4.1. Options overview
4.2. Static vs. Dynamic options
4.3. Meaningful file suffixes
4.4. Help and verbosity options
4.5. Using ghc ––make
4.6. GHC without ––make
4.7. Re-directing the compilation output(s)
4.8. Warnings and sanity-checking
4.9. Separate compilation
4.10. Packages
4.11. Optimisation (code improvement)
4.12. Options related to a particular phase
4.13. Using Concurrent Haskell
4.14. Using Parallel Haskell
4.15. Platform-specific Flags
4.16. Running a compiled program
4.17. Generating External Core Files
4.18. Debugging the compiler
4.19. Flag reference

GHC can work in one of three “modes”:

ghc ––interactive

Interactive mode, which is also available as ghci. Interactive mode is described in more detail in Chapter 3.

ghc ––make

In this mode, GHC will build a multi-module Haskell program automatically, figuring out dependencies for itself. If you have a straightforward Haskell program, this is likely to be much easier, and faster, than using make.

ghc [-E | -C | -S | -c]

This is the traditional batch-compiler mode, in which GHC can compile source files one at a time, or link objects together into an executable.

4.1. Options overview

GHC's behaviour is controlled by options, which for historical reasons are also sometimes referred to as command-line flags or arguments. Options can be specified in three ways: