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
:main
and:run
commands - 3.4.7. The
it
variable - 3.4.8. Type defaulting in GHCi
- 3.4.9. Using a custom interactive printing function
- 3.4.10. 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. 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. Recompilation checking
- 5.6.10. Interactive-mode options
- 5.6.11. Packages
- 5.6.12. Language options
- 5.6.13. Warnings
- 5.6.14. Optimisation levels
- 5.6.15. Individual optimisations
- 5.6.16. Profiling options
- 5.6.17. Program coverage options
- 5.6.18. C pre-processor options
- 5.6.19. Code generation options
- 5.6.20. Linking options
- 5.6.21. Plugin options
- 5.6.22. Replacing phases
- 5.6.23. Forcing options to particular phases
- 5.6.24. Platform-specific options
- 5.6.25. Compiler debugging options
- 5.6.26. Miscellaneous compiler options
- 5.7. Running a compiled program
- 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 hackers, debuggers, and over-interested souls
- 5.7.9. 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.10. GHC Backends
- 5.11. Options related to a particular phase
- 5.12. Using shared libraries
- 5.13. Debugging the compiler
- 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. New monadic failure desugaring mechanism
- 6.2.10. Overloaded lists
- 6.2.11. Rebindable syntax and the implicit Prelude import
- 6.2.12. Postfix operators
- 6.2.13. Tuple sections
- 6.2.14. Lambda-case
- 6.2.15. Empty case alternatives
- 6.2.16. Multi-way if-expressions
- 6.2.17. Local Fixity Declarations
- 6.2.18. More liberal syntax for function arguments
- 6.2.19. Typed Holes
- 6.2.20. Arrow notation
- 6.2.21. 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. Kind polymorphism
- 6.4.11.1. Overview of kind polymorphism
- 6.4.11.2. Overview of Type-in-Type
- 6.4.11.3. Principles of kind inference
- 6.4.11.4. Inferring the order of variables in a type/class declaration
- 6.4.11.5. Complete user-supplied kind signatures and polymorphic recursion
- 6.4.11.6. Standalone kind signatures and polymorphic recursion
- 6.4.11.7. Standalone kind signatures and declaration headers
- 6.4.11.8. Kind inference in closed type families
- 6.4.11.9. Kind inference in class instance declarations
- 6.4.11.10. Kind inference in type signatures
- 6.4.11.11. Explicit kind quantification
- 6.4.11.12. Implicit quantification in type synonyms and type family instances
- 6.4.11.13. Kind-indexed GADTs
- 6.4.11.14. Higher-rank kinds
- 6.4.11.15. Constraints in kinds
- 6.4.11.16. The kind
Type
- 6.4.11.17. Inferring dependency in datatype declarations
- 6.4.11.18. Inferring dependency in user-written
forall
s - 6.4.11.19. Kind defaulting without
PolyKinds
- 6.4.11.20. Pretty-printing in the presence of kind polymorphism
- 6.4.11.21. Datatype return kinds
- 6.4.12. Levity polymorphism
- 6.4.13. Type-Level Literals
- 6.4.14. Visible type application
- 6.4.15. Arbitrary-rank polymorphism
- 6.4.16. Impredicative polymorphism
- 6.4.17. Linear types
- 6.4.18. Custom compile-time errors
- 6.4.19. Deferring type errors to runtime
- 6.4.20. Roles
- 6.5. Records
- 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. Flexible contexts
- 6.8.3. Undecidable (or recursive) superclasses
- 6.8.4. Constrained class method types
- 6.8.5. Default method signatures
- 6.8.6. Nullary type classes
- 6.8.7. Functional dependencies
- 6.8.8. Instance declarations and resolution
- 6.8.8.1. Relaxed rules for the instance head
- 6.8.8.2. Formal syntax for instance declaration types
- 6.8.8.3. Relaxed rules for instance contexts
- 6.8.8.4. Instance termination rules
- 6.8.8.5. Undecidable instances
- 6.8.8.6. Overlapping instances
- 6.8.8.7. Instance signatures: type signatures in instance declarations
- 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.
LINE
pragma - 6.20.8.
COLUMN
pragma - 6.20.9.
RULES
pragma - 6.20.10.
SPECIALIZE
pragma - 6.20.11.
SPECIALIZE
instance pragma - 6.20.12.
UNPACK
pragma - 6.20.13.
NOUNPACK
pragma - 6.20.14.
SOURCE
pragma - 6.20.15.
COMPLETE
pragmas - 6.20.16.
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
- 8. Profiling
- 8.1. Cost centres and cost-centre stacks
- 8.2. Compiler options for profiling
- 8.3. Time and allocation profiling
- 8.4. Profiling memory usage
- 8.5.
hp2ps
– Rendering heap profiles to PostScript - 8.6. Profiling Parallel and Concurrent Programs
- 8.7. Observing Code Coverage
- 8.8. Using “ticky-ticky” profiling (for implementors)
- 9. Debugging compiled programs
- 10. What to do when something goes wrong
- 11. Hints
- 12. Other Haskell utility programs
- 13. Running GHC on Win32 systems
- 14. Known bugs and infelicities
- 14.1. Haskell standards vs. Glasgow Haskell: language non-compliance
- 14.1.1. Divergence from Haskell 98 and Haskell 2010
- 14.1.1.1. Lexical syntax
- 14.1.1.2. Context-free syntax
- 14.1.1.3. Expressions and patterns
- 14.1.1.4. Declarations and bindings
- 14.1.1.5. Typechecking of recursive binding groups
- 14.1.1.6. Default Module headers with -main-is
- 14.1.1.7. Module system and interface files
- 14.1.1.8. Numbers, basic types, and built-in classes
- 14.1.1.9. In
Prelude
support - 14.1.1.10. The Foreign Function Interface
- 14.1.1.11. Operator sections
- 14.1.2. GHC’s interpretation of undefined behaviour in Haskell 98 and Haskell 2010
- 14.1.1. Divergence from Haskell 98 and Haskell 2010
- 14.2. Known bugs or infelicities
- 14.1. Haskell standards vs. Glasgow Haskell: language non-compliance
- 15. Eventlog encodings
- 16. Care and feeding of your GHC User’s Guide