ghc [option|filename]
ghci [option|filename]
This manual page documents briefly the ghc and ghci commands. Note that ghci is not yet available on all architectures. Extensive documentation is available in various other formats including PDF and HTML; see below.
Each of GHC’s command line options is classified as either static or dynamic. A static flag may only be specified on the command line, whereas a dynamic flag may also be given in an OPTIONS pragma in a source file or set from the GHCi command-line with :set .
As a rule of thumb, all the language options are dynamic, as are the warning options and the debugging options.
The rest are static, with the notable exceptions of -v, -cpp, -fasm, -fvia-C, -fllvm, and -#include. The OPTIONS sections lists the status of each flag.
Common suffixes of file names for Haskell are:
object files for “way” ⟨way⟩; common ways are:
Build dynamic object files as well as static object files during compilation
Use the native code generator
Generate byte-code
Generate code for linking against dynamic libraries
Compile using the LLVM code generator
Omit code generation
Generate object code
Generate position-independent code (where available)
Generate code for a position-independent executable (where available)
Always write interface files
C-\- pass sanity checking
Turn on internal sanity checking
Dump final assembly
Dump the result of the synthetic instruction expansion pass.
Dump assembly augmented with register liveness
Dump initial assembly
Dump the result of register allocation
Dump the build/spill stages of the -fregs-graph register allocator.
Dump statistics from the register allocator.
Dump interpreter byte code
Dump the final C-\- output
Dump the results of the C-\- CAF analysis pass.
Dump the results of common block elimination
Dump the results of the C-\- control flow optimisation pass.
Dump the results of the CPS pass
Dump STG-to-C-\- output
Dump the results of the C-\- info table augmentation pass.
Dump the results of proc-point analysis
Dump the results of the C-\- proc-point map pass.
Dump raw C-\-
Dump the results of the C-\- sinking pass.
Dump the results of the C-\- stack layout pass.
Dump the results of the C-\- proc-point splitting pass.
Dump the results of switch lowering passes
Show output from each C-\- pipeline pass
Print a one-line summary of the size of the Core program at the end of the optimisation pipeline
Dump CSE output
Dump deriving output
Dump desugarer output.
Trace exhaustiveness checker
Dump foreign export stubs
Trace interface files
Dump inlining info
Dump error messages as JSON documents
Dump LLVM intermediate code.
Dump occurrence analysis output
Dump the results of C-\- to C-\- optimising passes
Dump parse tree
Dump parser output as a syntax tree
Dump prepared core
Dump renamer output
Dump renamer output as a syntax tree
Renamer stats
Trace renamer
Dump rule firing info
Dump detailed rule firing info
Dump rewrite rules
Dump final simplifier output
Dump output from each simplifier iteration
Dump simplifier stats
Dump specialiser output
Dump TH spliced expressions, and what they evaluate to
Dump final STG
Dump strictness signatures
Dump strictness analyser output
Dump typechecker output
Dump typechecker output as a syntax tree
Trace typechecker
Dump per-pass timing and allocation statistics
Dump to files instead of stdout
Dump type signatures
Dump worker-wrapper output
Show statistics for fast string usage when finished
Print values of type Word# in hexadecimal.
Start UniqSupply allocation from ⟨s⟩.
Dump information about inlining decisions
Suppress unsolicited debugging output
Print single alternative case expressions as strict lets.
Set the width of debugging output. For example -dppr-cols200
Turn on debug printing (more verbose)
Set the depth for printing expressions in error msgs
Dump information about potential rule application
Print out each pass name as it happens
STG pass sanity checking
In dumps, suppress everything (except for uniques) that is suppressible.
Suppress the printing of coercions in Core dumps to make them shorter
Suppress extended information about identifiers where they are bound
Suppress the printing of module qualification prefixes
Suppress the printing of closure free variable lists in STG output
Suppress “ticks” in the pretty-printer output.
Suppress timestamps in dumps
Suppress type applications
Suppress type signatures
Suppress the printing of the stable unfolding of a variable at its binding site
Suppress the printing of uniques in debug output (easier to use diff)
Suppress the printing of variable kinds
Dump evaluated TH declarations into *.th.hs files
Set the increment for the generated Unique‘s to ⟨i⟩.
Show output from each core-to-core pass
Show output from each STG-to-STG pass
Compile with alignment checks for all info table dereferences.
Insert error expressions after bottoming expressions; useful when debugging the compiler.
Intruct LLVM to fill dead STG registers with garbage
Align functions at given boundary.
Produce DWARF debug information in compiled object files. ⟨n⟩ can be 0, 1, or 2, with higher numbers producing richer output. If ⟨n⟩ is omitted, level 2 is assumed.
Run the C pre-processor on Haskell source files
Define a symbol in the C pre-processor
Add ⟨dir⟩ to the directory search list for #include files
Undefine a symbol in the C pre-processor
Empty the import directory list
add ⟨dir⟩, ⟨dir2⟩, etc. to import path
Set the number of entries GHCi keeps for :history. See The GHCi Debugger.
(Debugging only) check for space leaks when loading new modules in GHCi.
Use current directory for the GHCi command history file .ghci-history.
No longer set the special variable it.
Show the names of modules that GHCi loaded after a :load command.
Read additional .ghci files
Disable reading of .ghci files
Select the function to use for printing evaluated expressions in GHCi
See Modes of operation.
Dump the new interface to stdout
Show the differences vs. the old interface
Dump a minimal set of imports
Retain intermediate .hc files.
Retain intermediate .hi files (the default).
Retain intermediate LLVM .ll files. Implies -fllvm.
Retain intermediate .o files (the default).
Retain intermediate .s files.
Retain all intermediate temporary files.
Stop after generating object (.o) file
Use the debugging runtime
Set the install name (via -install_name passed to Apple’s linker), specifying the full install path of the library file. Any libraries or executables that link with it later will pick up that path as their runtime search location for it. (Darwin/OS X only)
Build dynamically-linked object files and executables
Selects one of a number of modes for finding shared libraries at runtime.
Enable runtime event tracing
Do not embed the manifest in the executable (Windows only)
Do not generate a manifest file (Windows only)
Don’t generate an import library for a DLL (Windows only)
On Darwin/OS X/iOS only, link in the framework ⟨name⟩. This option corresponds to the -framework option for Apple’s Linker.
On Darwin/OS X/iOS only, add ⟨dir⟩ to the list of directories searched for frameworks. This option corresponds to the -F option for Apple’s Linker.
When linking a binary executable, this inserts the flag -Wl,--whole-archive before any -l flags for Haskell libraries, and -Wl,--no-whole-archive afterwards
Add ⟨dir⟩ to the list of directories searched for libraries
Link in library ⟨lib⟩
Set main module and function
Don’t assume this program contains main
Don’t print RTS suggestions about linking with -rtsopts[=⟨none|some|all|ignore|ignoreAll⟩].
Expose package ⟨pkg⟩
Instruct the linker to produce a position-independent executable.
This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table. Currently Linux and Windows/MinGW32 only. This is equivalent to using -optl -rdynamic on Linux, and -optl -export-all-symbols on Windows.
Control whether the RTS behaviour can be tweaked via command-line flags and the GHCRTS environment variable. Using none means no RTS flags can be given; some means only a minimum of safe options can be given (the default); all (or no argument at all) means that all RTS flags are permitted; ignore means RTS flags can be given, but are treated as regular arguments and passed to the Haskell program as arguments; ignoreAll is the same as ignore, but GHCRTS is also ignored. -rtsopts does not affect -with-rtsopts behavior; flags passed via -with-rtsopts are used regardless of -rtsopts.
Generate a shared library (as opposed to an executable)
Split objects (for libraries)
Split sections for link-time dead-code stripping
Use static Haskell libraries
Generate a standalone static library (as opposed to an executable). This is useful when cross compiling. The library together with all its dependencies ends up in in a single static library that can be linked against.
Use the threaded runtime
Set the default RTS options to ⟨opts⟩.
Run interpreted code in a separate process
Deprecated. Enable most language extensions; see Language options for exactly which ones.
(GHC as a C compiler only) Use this ghcversion.h file
Set the minimum size of the heap to ⟨size⟩
When compiling with --make, compile ⟨n⟩ modules in parallel.
run GHC with the given frontend plugin; see Frontend plugins for details.
Display help
display information about the compiler
Interactive mode - normally used by just running ghci; see Using GHCi for details.
Build a multi-module Haskell program, automatically figuring out dependencies. Likely to be much easier, and faster, than using make; see Using ghc –make for details.
DLL-creation mode (Windows only)
display GHC version (numeric only)
display GHC library directory
display the contents of an interface file.
display the supported command line options
display the supported language extensions
display GHC version
Evaluate expr; see Expression evaluation mode for details.
generate dependency information suitable for use in a Makefile; see Dependency generation for details.
Enable shortcutting on assembly. Implied by -O2.
Enable call-arity optimisation. Implied by -O.
Enable constant folding in case expressions. Implied by -O.
Enable case-merging. Implied by -O.
Enable Cmm common block elimination. Implied by -O.
Enable Cmm sinking. Implied by -O.
Turn on CPR analysis in the demand analyser. Implied by -O.
Turn on specialisation of overloaded functions imported from other modules.
Enable common sub-expression elimination. Implied by -O.
Make dictionary-valued expressions seem cheap to the optimiser.
Make dictionaries strict
Use a special demand transformer for dictionary selectors. Always enabled by default.
Enable eta-reduction. Implied by -O.
Enable lambda eta-expansion. Always enabled by default.
Turn on eager blackholing
Switch on all rewrite rules (including rules generated by automatic specialisation of overloaded functions). Implied by -O.
Enable excess intermediate precision
Enables exitification optimisation. Implied by -O.
Expose all unfoldings, even for very large or recursive functions.
Turn on the float-in transformation. Implied by -O.
Turn on full laziness (floating bindings outwards). Implied by -O.
Allow worker-wrapper to convert a function closure into a thunk if the function does not use any of its arguments. Off by default.
Ignore assertions in the source. Implied by -O.
Ignore pragmas in interface files. Implied by -O0 only.
Run demand analysis again, at the end of the simplification pipeline
Run a late specialisation pass
Turn on the liberate-case transformation. Implied by -O2.
default: 2000. Set the size threshold for the liberate-case transformation to ⟨n⟩
Pass vector value in vector registers for function calls
Turn saturated self-recursive tail-calls into local jumps in the generated assembly. Implied by -O.
default: 128. Set the maximum size of inline array allocations to ⟨n⟩ bytes (default: 128).
default: 32. Inline memcpy calls if they would generate no more than ⟨n⟩ pseudo instructions.
default: 32. Inline memset calls if they would generate no more than ⟨n⟩ pseudo instructions
default: 4. Set the max iterations for the simplifier.
default: 4. Set the maximum number of patterns to display in warnings about non-exhaustive ones.
default: 10. If a worker has that many arguments, none will be unpacked anymore.
Turn off the coercion optimiser
Turn off pre-inlining
Turn off the state hackwhereby any lambda with a real-world state token as argument is considered to be single-entry. Hence OK to inline things inside it.
Don’t generate interface pragmas. Implied by -O0 only.
Omit heap checks when no allocation is being performed.
Use a slower but better algorithm for ApplicativeDo
Make GHC be more precise about its treatment of bottom (but see also -fno-state-hack). In particular, GHC will not eta-expand through a case expression.
Use the graph colouring register allocator for register allocation in the native code generator. Implied by -O2.
Use the iterative coalescing graph colouring register allocator in the native code generator.
default: 100. Set the percentage factor for simplifier ticks.
default: 2. Set the number of phases for the simplifier. Ignored with -O0.
When solving constraints, try to eagerly solve super classes using available dictionaries.
Turn on the SpecConstr transformation. Implied by -O2.
default: 3.* Set to ⟨n⟩ the maximum number of specialisations that will be created for any one function by the SpecConstr transformation.
Specialize a call with an explicit constructor argument, even if the argument is not scrutinised in the body of the function
default: 2000. Set the size threshold for the SpecConstr transformation to ⟨n⟩.
Turn on specialisation of overloaded functions. Implied by -O.
Turn on specialisation of overloaded functions regardless of size, if unfolding is available
Turn on the static argument transformation.
Enable common sub-expression elimination on the STG intermediate language
Turn on strictness analysis. Implied by -O. Implies -fworker-wrapper
Run an additional strictness analysis before simplifier phase ⟨n⟩
Flatten strict constructor fields with a pointer-sized representation. Implied by -O.
Flatten strict constructor fields
default: 750. Tweak unfolding settings.
default: 30. Tweak unfolding settings.
default: 60. Tweak unfolding settings.
default: 1.5. Tweak unfolding settings.
default: 60. Tweak unfolding settings.
Clear the package db stack.
Expose package ⟨pkg⟩ and set it to be distrusted. See Safe Haskell.
Distrust all packages by default. See Safe Haskell.
Enable Safe Haskell trusted package requirement for trustworthy modules.
Add the global package db to the stack.
Hide all packages by default
Hide package ⟨pkg⟩
Ignore package ⟨pkg⟩
Don’t automatically link in the base and rts packages.
Remove the global package db from the stack.
Remove the user’s package db from the stack.
Expose package ⟨pkg⟩
Add ⟨file⟩ to the package db stack.
Use the specified package environment.
Expose package by id ⟨unit-id⟩
Compile to be part of unit (i.e. package) ⟨unit-id⟩
Expose package ⟨pkg⟩ and set it to be trusted. See Safe Haskell.
Add the user’s package db to the stack.
Stop after generating C (.hc file)
Stop after generating object (.o) file
Stop after preprocessing (.hspp file)
Enable the use of a pre-processor (set with -pgmF ⟨cmd⟩)
Stop after generating assembly (.s file)
Override default behaviour for source files
Use ⟨cmd⟩ as the assembler
Use ⟨cmd⟩ as the C compiler
Use ⟨cmd⟩ as the DLL generator
Use ⟨cmd⟩ as the pre-processor (with -F only)
Use ⟨cmd⟩ as the external interpreter command.
Use ⟨cmd⟩ as the literate pre-processor
Use ⟨cmd⟩ as the linker
Use ⟨cmd⟩ as the LLVM compiler
Use ⟨cmd⟩ as the command for libtool (with -staticlib only).
Use ⟨cmd⟩ as the LLVM optimiser
Use ⟨cmd⟩ as the C pre-processor (with -cpp only)
Use ⟨cmd⟩ as the splitter
Use ⟨cmd⟩ as the program for embedding manifests on Windows.
pass ⟨option⟩ to the assembler
pass ⟨option⟩ to the C compiler
pass ⟨option⟩ to the DLL generator
pass ⟨option⟩ to the custom pre-processor
pass ⟨option⟩ to the interpreter sub-process.
pass ⟨option⟩ to the literate pre-processor
pass ⟨option⟩ to the linker
pass ⟨option⟩ to the LLVM compiler
pass ⟨option⟩ to the LLVM optimiser
pass ⟨option⟩ to cpp (with -cpp only)
pass ⟨option⟩ to windres.
Give arguments to a plugin module; module must be specified with -fplugin=⟨module⟩
Load a plugin exported by a given module
Hide all packages for plugins by default
Expose ⟨pkg⟩ for plugins
Expose ⟨pkg-id⟩ for plugins
Disables any previous -fprof-auto, -fprof-auto-top, or -fprof-auto-exported options.
Disables any previous -fprof-cafs option.
Do not collect entry counts
Auto-add SCC\ s to all bindings not marked INLINE
Auto-add SCC\ s to all call sites
Auto-add SCC\ s to all exported bindings not marked INLINE
Auto-add SCC\ s to all top-level bindings not marked INLINE
Auto-add SCC\ s to all CAFs
Turn on profiling
Turn off recompilation checking. This is implied by any -ddump-X option when compiling a single file (i.e. when using -c).
Do not recompile modules just to match changes to HPC flags. This is especially useful for avoiding recompilation when using GHCi, and is enabled by default for GHCi.
Do not recompile modules just to match changes to optimisation flags. This is especially useful for avoiding recompilation when using GHCi, and is enabled by default for GHCi.
Regard ⟨file⟩ as “stable”; i.e., exclude it from having dependencies on it.
Dump module cycles
Use ⟨file⟩ as the makefile
Make dependencies that declare that files with suffix .⟨suf⟩⟨osuf⟩ depend on interface files with suffix .⟨suf⟩hi
redirect dump files
set the suffix to use for intermediate C files
set directory for interface files
set the suffix to use for interface files
Regard modules imported from packages as unstable
set output filename
set directory for object files
set the filename in which to put the interface
set the output file suffix
set output directory
redirect FFI stub files
set the directory for temporary files
default: off. Toggles whether refinements where one or more or more of the holes are abstract are reported.
Use colors in error messages
Whether to show snippets of original source code
Output full span in error messages
hide module source and object paths
default: 6. Set the maximum number of refinement hole fits for typed holes to display in type error messages.
default: 6. Set the maximum number of bindings to display in type error messages.
default: 6. Set the maximum number of valid hole fits for typed holes to display in type error messages.
Disables showing a list of valid hole fits for typed holes in type error messages.
Disables the sorting of the list of valid hole fits for typed holes in type error messages.
Distinguish between equality relations when printing
In type errors, also print type-synonym-expanded types.
Print coercions in types
Print explicit forall quantification in types. See also -XExplicitForAll
Print explicit kind foralls and kind arguments in types. See also -XKindSignatures
Print RuntimeRep variables in types which are runtime-representation polymorphic.
Print RuntimeRep variables in types which are runtime-representation polymorphic.
display all available instances in type error messages
Print extra information from typechecker.
Use unicode syntax when printing expressions, types and kinds. See also -XUnicodeSyntax
default: off. Sets the level of refinement of the refinement hole fits, where level n means that hole fits of up to n holes will be considered.
Show constraints when reporting typed holes.
Toggles whether to show the type of the additional holes in refinement hole fits.
Toggles whether to show the provenance of the valid hole fits in the output.
Toggles whether to show the type application of the valid hole fits in the output.
Toggles whether to show what type each quantified variable takes in a valid hole fit.
Toggles whether to show the type of the valid hole fits in the output.
Unclutter the list of valid hole fits by not showing provenance nor type applications of suggestions.
Summarise timing stats for GHC (same as +RTS -tstderr).
verbose mode (equivalent to -v3)
set verbosity level
Convert variable out of scope variables errors into warnings. Implied by -fdefer-type-errors. See also -Wdeferred-out-of-scope-variables.
Turn type errors into warnings, deferring the error until runtime. Implies -fdefer-typed-holes and -fdefer-out-of-scope-variables. See also -Wdeferred-type-errors
Convert typed hole errors into warnings, deferring the error until runtime. Implied by -fdefer-type-errors. See also -Wtyped-holes.
Make suggestions for mis-spelled names.
the iteration limit for the pattern match checker
show which group an emitted warning belongs to.
enable normal warnings
disable all warnings
enable almost all warnings (details in Warnings and sanity-checking)
warn when specialisation of any overloaded function fails.
(deprecated) warn on definitions conflicting with the Applicative-Monad Proposal (AMP)
enable future compatibility warnings (details in Warnings and sanity-checking)
warn on uses of the #if directive on undefined identifiers
Report warnings when variable out-of-scope errors are deferred until runtime. See -fdefer-out-of-scope-variables.
Report warnings when deferred type errors are enabled. This option is enabled by default. See -fdefer-type-errors.
warn about uses of commandline flags that are deprecated
warn about uses of functions & types that have warnings or deprecated pragmas. Alias for -Wwarnings-deprecations
warn about dodgy exports
warn about dodgy foreign imports
warn about dodgy imports
warn when a constraint appears duplicated in a type signature
warn when an entity is exported multiple times
warn about enumerations that are empty
make warnings fatal
enable all warnings supported by GHC
warn when a .hi file in the current directory shadows a library
warn about uses of Prelude numeric conversions that are probably the identity (and hence could be omitted)
warn when kind variables are brought into scope implicitly despite the “forall-or-nothing” rule
warn when the Prelude is implicitly imported
warn about inaccessible code
warn when a pattern match could fail
warn when a record update could fail
warn when a pattern match in a lambda expression or pattern binding could fail
Warn if a rewrite RULE might fail to fire because the function might be inlined before the rule has a chance to fire. See How rules interact with INLINE/NOINLINE pragmas.
warn when specialisation of an imported, overloaded function fails.
warn when a module declaration does not explicitly list all exports
warn about top-level functions without signatures, only if they are exported. takes precedence over -Wmissing-signatures
(deprecated) warn about top-level functions without signatures, only if they are exported. takes precedence over -Wmissing-signatures
warn when fields of a record are uninitialised
warn when encountering a home module imported, but not listed on the command line. Useful for cabal to ensure GHC won’t pick up modules, not listed neither in exposed-modules, nor in other-modules.
warn when an import declaration does not explicitly list all the names brought into scope
warn about polymorphic local bindings without signatures
(deprecated) warn about polymorphic local bindings without signatures
warn when class methods are undefined
Warn when a failable pattern is used in a do-block that does not have a MonadFail instance.
warn when pattern synonyms do not have type signatures
warn about top-level functions without signatures
warn when the Monomorphism Restriction is applied
warn when names are shadowed
Disables all warnings enabled by -Wcompat.
warn when Applicative or Monad instances have noncanonical definitions of return, pure, (>>), or (*>). See flag description in Warnings and sanity-checking for more details.
warn when Monad or MonadFail instances have noncanonical definitions of fail. See flag description in Warnings and sanity-checking for more details.
warn when Semigroup or Monoid instances have noncanonical definitions of (<>) or mappend. See flag description in Warnings and sanity-checking for more details.
warn when the module contains orphan instance declarations or rewrite rules
warn about literals that will overflow their type
warn about overlapping patterns
warn when defining a partial record field.
warn about holes in partial type signatures when -XPartialTypeSignatures is enabled. Not applicable when -XPartialTypesignatures is not enabled, in which case errors are generated for such holes. See Partial Type Signatures.
Have the compiler warn about redundant constraints in type signatures.
warn if the module being compiled is regarded to be safe.
warn when a Monoid is not Semigroup, and on non- Semigroup definitions of (<>)?
2arn about class constraints in a type signature that can be simplified using a top-level instance declaration.
warn about binding the (*) type operator despite -XStarIsType
warn when * is used to mean Data.Kind.Type
warn if there are tabs in the source file
warn if the module being compiled is marked as Trustworthy but it could instead be marked as Safe, a more informative bound.
warn when defaulting happens
Report warnings when typed hole errors are deferred until runtime. See -fdefer-typed-holes.
warn on pattern bind of unlifted variable that is neither bare nor banged
warn about uses of pragmas that GHC doesn’t recognise
throw a warning when an unreconised -W... flag is encountered on the command line.
warn if the module being compiled is regarded to be unsafe. See Safe Haskell
warn about use of an unsupported calling convention
Warn when using -fllvm with an unsupported version of LLVM.
warn if promoted constructors are not ticked
warn about bindings that are unused. Alias for -Wunused-top-binds, -Wunused-local-binds and -Wunused-pattern-binds
warn about do bindings that appear to throw away values of types other than ()
warn about type variables in user-written forall\s that are unused
warn about unnecessary imports
warn about local bindings that are unused
warn about variables in patterns that aren’t used
warn about pattern match bindings that are unused
warn about top-level bindings that are unused
warn about unused type variables which arise from patterns in type family and data family instances
make warnings non-fatal
warn about uses of functions & types that have warnings or deprecated pragmas
warn about do bindings that appear to throw away monadic values that you should have bound instead
Copyright 2015. The University Court of the University of Glasgow. All rights reserved.