Welcome to the GHC User’s Guide¶
Contents:
- 1. Introduction
- 2. Release notes
- 3. Using GHCi
- 3.1. Introduction to GHCi
- 3.2. Loading source files
- 3.3. Loading compiled code
- 3.4. Interactive evaluation at the prompt
- 3.4.1. I/O actions at the prompt
- 3.4.2. Using
do
notation at the prompt - 3.4.3. Multiline input
- 3.4.4. Type, class and other declarations
- 3.4.5. What’s really in scope at the prompt?
- 3.4.6. The
it
variable - 3.4.7. Type defaulting in GHCi
- 3.4.8. Using a custom interactive printing function
- 3.4.9. Stack Traces in GHCi
- 3.5. The GHCi Debugger
- 3.6. Invoking GHCi
- 3.7. GHCi commands
- 3.8. The
:set
and:seti
commands - 3.9. The
.ghci
and.haskeline
files - 3.10. Compiling to object code inside GHCi
- 3.11. Running the interpreter in a separate process
- 3.12. Running the interpreter on a different host
- 3.13. Building GHCi libraries
- 3.14. FAQ and Things To Watch Out For
- 4. Using runghc
- 5. Using GHC
- 5.1. Using GHC
- 5.2. Warnings and sanity-checking
- 5.3. Optimisation (code improvement)
- 5.4. Using Concurrent Haskell
- 5.5. Using SMP parallelism
- 5.6. Flag reference
- 5.6.1. Verbosity options
- 5.6.2. Alternative modes of operation
- 5.6.3. Which phases to run
- 5.6.4. Redirecting output
- 5.6.5. Keeping intermediate files
- 5.6.6. Temporary files
- 5.6.7. Finding imports
- 5.6.8. Interface file options
- 5.6.9. Extended interface file options
- 5.6.10. Recompilation checking
- 5.6.11. Interactive-mode options
- 5.6.12. Packages
- 5.6.13. Language options
- 5.6.14. Warnings
- 5.6.15. Optimisation levels
- 5.6.16. Individual optimisations
- 5.6.17. Profiling options
- 5.6.18. Program coverage options
- 5.6.19. C pre-processor options
- 5.6.20. Code generation options
- 5.6.21. Linking options
- 5.6.22. Plugin options
- 5.6.23. Replacing phases
- 5.6.24. Forcing options to particular phases
- 5.6.25. Platform-specific options
- 5.6.26. Compiler debugging options
- 5.6.27. Miscellaneous compiler options
- 5.7. Runtime system (RTS) options
- 5.7.1. Setting RTS options
- 5.7.2. Miscellaneous RTS options
- 5.7.3. RTS options to control the garbage collector
- 5.7.4. RTS options to produce runtime statistics
- 5.7.5. RTS options for concurrency and parallelism
- 5.7.6. RTS options for profiling
- 5.7.7. Tracing
- 5.7.8. RTS options for Haskell program coverage
- 5.7.9. RTS options for hackers, debuggers, and over-interested souls
- 5.7.10. Getting information about the RTS
- 5.8. Filenames and separate compilation
- 5.8.1. Haskell source files
- 5.8.2. Output files
- 5.8.3. The search path
- 5.8.4. Redirecting the compilation output(s)
- 5.8.5. Keeping Intermediate Files
- 5.8.6. Redirecting temporary files
- 5.8.7. Other options related to interface files
- 5.8.8. Options related to extended interface files
- 5.8.9. The recompilation checker
- 5.8.10. How to compile mutually recursive modules
- 5.8.11. Module signatures
- 5.8.12. Using
make
- 5.8.13. Dependency generation
- 5.8.14. Orphan modules and instance declarations
- 5.9. Packages
- 5.9.1. Using Packages
- 5.9.2. The
main
package - 5.9.3. Consequences of packages for the Haskell language
- 5.9.4. Thinning and renaming modules
- 5.9.5. Package Databases
- 5.9.6. Installed package IDs, dependencies, and broken packages
- 5.9.7. Package management (the
ghc-pkg
command) - 5.9.8. Building a package from Haskell source
- 5.9.9.
InstalledPackageInfo
: a package specification - 5.9.10. Linking against C++ libraries
- 5.10. GHC Backends
- 5.11. Options related to a particular phase
- 5.12. Using shared libraries
- 5.13. Debugging the compiler
- 5.13.1. Dumping out compiler intermediate structures
- 5.13.1.1. Front-end
- 5.13.1.2. Type-checking and renaming
- 5.13.1.3. Core representation and simplification
- 5.13.1.4. STG representation
- 5.13.1.5. C-- representation
- 5.13.1.6. LLVM code generator
- 5.13.1.7. C code generator
- 5.13.1.8. Native code generator
- 5.13.1.9. JavaScript code generator
- 5.13.1.10. Miscellaneous backend dumps
- 5.13.2. Formatting dumps
- 5.13.3. Suppressing unwanted information
- 5.13.4. Checking for consistency
- 5.13.5. Checking for determinism
- 5.13.6. Other
- 5.13.1. Dumping out compiler intermediate structures
- 6. Language extensions
- 6.1. Introduction
- 6.2. Syntax
- 6.2.1. Unicode syntax
- 6.2.2. The magic hash
- 6.2.3. The recursive do-notation
- 6.2.4. Applicative do-notation
- 6.2.5. Qualified do-notation
- 6.2.6. Parallel List Comprehensions
- 6.2.7. Generalised (SQL-like) List Comprehensions
- 6.2.8. Monad comprehensions
- 6.2.9. Overloaded lists
- 6.2.10. Rebindable syntax and the implicit Prelude import
- 6.2.11. Postfix operators
- 6.2.12. Tuple sections
- 6.2.13. Lambda-case
- 6.2.14. Empty case alternatives
- 6.2.15. Multi-way if-expressions
- 6.2.16. Local Fixity Declarations
- 6.2.17. More liberal syntax for function arguments
- 6.2.18. Typed Holes
- 6.2.19. Arrow notation
- 6.2.20. Lexical negation
- 6.3. Import and export
- 6.4. Types
- 6.4.1. Data types with no constructors
- 6.4.2. Data type contexts
- 6.4.3. Infix type constructors, classes, and type variables
- 6.4.4. Type operators
- 6.4.5. Liberalised type synonyms
- 6.4.6. Existentially quantified data constructors
- 6.4.7. Declaring data types with explicit constructor signatures
- 6.4.8. Generalised Algebraic Data Types (GADTs)
- 6.4.9. Type families
- 6.4.10. Datatype promotion
- 6.4.11. Unique syntax for type-level lists and tuples
- 6.4.12. Type-level data declarations
- 6.4.13. Kind polymorphism
- 6.4.13.1. Overview of kind polymorphism
- 6.4.13.2. Overview of Type-in-Type
- 6.4.13.3. Principles of kind inference
- 6.4.13.4. Kind inference in type signatures
- 6.4.13.5. Explicit kind quantification
- 6.4.13.6. Inferring the order of variables in a type/class declaration
- 6.4.13.7. Complete user-supplied kind signatures and polymorphic recursion
- 6.4.13.8. Standalone kind signatures and polymorphic recursion
- 6.4.13.9. Standalone kind signatures and declaration headers
- 6.4.13.10. Kind inference in data type declarations
- 6.4.13.11. Kind inference for data/newtype instance declarations
- 6.4.13.12. Kind inference in class instance declarations
- 6.4.13.13. Kind inference in type synonyms and type family instances
- 6.4.13.14. Kind inference in closed type families
- 6.4.13.15. Higher-rank kinds
- 6.4.13.16. The kind
Type
- 6.4.13.17. Inferring dependency in datatype declarations
- 6.4.13.18. Inferring dependency in user-written
forall
s - 6.4.13.19. Kind defaulting without
PolyKinds
- 6.4.13.20. Pretty-printing in the presence of kind polymorphism
- 6.4.13.21. Datatype return kinds
- 6.4.14. Representation polymorphism
- 6.4.15. Type-Level Literals
- 6.4.16. Visible type application
- 6.4.17. Type abstractions
- 6.4.18. Required type arguments
- 6.4.19. Arbitrary-rank polymorphism
- 6.4.20. Impredicative polymorphism
- 6.4.21. Linear types
- 6.4.22. Custom compile-time errors
- 6.4.23. Deferring type errors to runtime
- 6.4.24. Roles
- 6.5. Records
- 6.5.1. Record field name resolution
- 6.5.2. Traditional record syntax
- 6.5.3. Field selectors and
TypeApplications
- 6.5.4. Record field disambiguation
- 6.5.5. Duplicate record fields
- 6.5.6. Field selectors
- 6.5.7. Record puns
- 6.5.8. Record wildcards
- 6.5.9. Record field selector polymorphism
- 6.5.10. Overloaded record dot
- 6.5.11. Overloaded record update
- 6.6. Deriving mechanism
- 6.6.1. Deriving instances for empty data types
- 6.6.2. Inferred context for deriving clauses
- 6.6.3. Stand-alone deriving declarations
- 6.6.4. Deriving instances of extra classes (
Data
, etc.) - 6.6.5. Generalised derived instances for newtypes
- 6.6.6. Deriving any other class
- 6.6.7. Deriving strategies
- 6.6.8. Deriving via
- 6.7. Patterns
- 6.8. Class and instances declarations
- 6.8.1. Multi-parameter type classes
- 6.8.2. Undecidable (or recursive) superclasses
- 6.8.3. Constrained class method types
- 6.8.4. Default method signatures
- 6.8.5. Detailed requirements for default type signatures
- 6.8.6. Nullary type classes
- 6.8.7. Functional dependencies
- 6.8.8. Instance declarations and resolution
- 6.9. Literals
- 6.10. Constraints
- 6.11. Type signatures
- 6.12. Bindings and generalisation
- 6.13. Template Haskell
- 6.14. Bang patterns and Strict Haskell
- 6.15. Parallel and Concurrent
- 6.16. Unboxed types and primitive operations
- 6.17. Foreign function interface (FFI)
- 6.18. Safe Haskell
- 6.19. Miscellaneous
- 6.20. Pragmas
- 6.20.1.
LANGUAGE
pragma - 6.20.2.
OPTIONS_GHC
pragma - 6.20.3.
INCLUDE
pragma - 6.20.4.
WARNING
andDEPRECATED
pragmas - 6.20.5.
MINIMAL
pragma - 6.20.6.
INLINE
andNOINLINE
pragmas - 6.20.7.
OPAQUE
pragma - 6.20.8.
LINE
pragma - 6.20.9.
COLUMN
pragma - 6.20.10.
RULES
pragma - 6.20.11.
SPECIALIZE
pragma - 6.20.12.
SPECIALIZE
instance pragma - 6.20.13.
UNPACK
pragma - 6.20.14.
NOUNPACK
pragma - 6.20.15.
SOURCE
pragma - 6.20.16.
COMPLETE
pragmas - 6.20.17.
OVERLAPPING
,OVERLAPPABLE
,OVERLAPS
, andINCOHERENT
pragmas
- 6.20.1.
- 7. Extending and using GHC as a Library
- 7.1. Source annotations
- 7.2. Using GHC as a Library
- 7.3. Compiler Plugins
- 7.4. Referring to back ends
- 8. Profiling
- 8.1. Cost centres and cost-centre stacks
- 8.2. Profiling and foreign calls
- 8.3. Compiler options for profiling
- 8.4. Time and allocation profiling
- 8.5. Profiling memory usage
- 8.6.
hp2ps
– Rendering heap profiles to PostScript - 8.7. Profiling Parallel and Concurrent Programs
- 8.8. Observing Code Coverage
- 8.9. Using “ticky-ticky” profiling (for implementors)
- 9. Debugging compiled programs
- 10. What to do when something goes wrong
- 11. Hints
- 11.1. Sooner: producing a program more quickly
- 11.2. Faster: producing a program that runs quicker
- 11.3. Smaller: producing a program that is smaller
- 11.4. Thriftier: producing a program that gobbles less heap space
- 11.5. Controlling inlining via optimisation flags.
- 11.6. Understanding how OS memory usage corresponds to live data
- 12. Other Haskell utility programs
- 13. Running GHC on Win32 systems
- 14. FFI and the JavaScript Backend
- 15. Using the GHC WebAssembly backend
- 16. Known bugs and infelicities
- 16.1. Haskell standards vs. Glasgow Haskell: language non-compliance
- 16.1.1. Divergence from Haskell 98 and Haskell 2010
- 16.1.1.1. Lexical syntax
- 16.1.1.2. Context-free syntax
- 16.1.1.3. Expressions and patterns
- 16.1.1.4. Failable patterns
- 16.1.1.5. Typechecking of recursive binding groups
- 16.1.1.6. Default Module headers with -main-is
- 16.1.1.7. Module system and interface files
- 16.1.1.8. Numbers, basic types, and built-in classes
- 16.1.1.9. In
Prelude
support - 16.1.1.10. The Foreign Function Interface
- 16.1.2. GHC’s interpretation of undefined behaviour in Haskell 98 and Haskell 2010
- 16.1.1. Divergence from Haskell 98 and Haskell 2010
- 16.2. Known bugs or infelicities
- 16.1. Haskell standards vs. Glasgow Haskell: language non-compliance
- 17. Eventlog encodings
- 18. Glossary
- 19. Care and feeding of your GHC User’s Guide