Man pages sections > man1 > ghc

ghc - the Glasgow Haskell Compiler

GHC(1) Glasgow Haskell Compiler GHC(1)


ghc - the Glasgow Haskell Compiler


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:
Haskell source code; preprocess, compile
literate Haskell source; unlit, preprocess, compile
Interface file; contains information about exported symbols
intermediate C files
object files for "way" ⟨way⟩; common ways are:
built with profiling

interface files for "way" ⟨way⟩; common ways are:


Code generation
-fasm -fllvm -fno-code -fwrite-interface -fbyte-code -fobject-code -g⟨n⟩ -dynamic -dynamic-too
Debugging the compiler
-dcore-lint -ddump-to-file -ddump-asm -ddump-bcos -ddump-cmm -ddump-core-stats -ddump-cse -ddump-deriv -ddump-ds -ddump-foreign -ddump-hpc -ddump-inlinings -ddump-llvm -ddump-occur-anal -ddump-opt-cmm -ddump-parsed -ddump-prep -ddump-rn -ddump-rule-firings -ddump-rule-rewrites -ddump-rules -ddump-vect -ddump-simpl -ddump-simpl-iterations -ddump-spec -ddump-splices -ddump-stg -ddump-stranal -ddump-str-signatures -ddump-tc -dth-dec-file -ddump-types -ddump-worker-wrapper -ddump-if-trace -ddump-tc-trace -ddump-vt-trace -ddump-rn-trace -ddump-rn-stats -ddump-simpl-stats -dno-debug-output -dppr-debug -dppr-user-length -dppr-cols⟨N⟩ -dppr-case-as-let -dsuppress-all -dsuppress-uniques -dsuppress-idinfo -dsuppress-unfoldings -dsuppress-module-prefixes -dsuppress-type-signatures -dsuppress-type-applications -dsuppress-coercions -dsource-stats -dcmm-lint -dstg-lint -dstg-stats -dverbose-core2core -dverbose-stg2stg -dshow-passes -dfaststring-stats -frule-check
C pre-processor
-cpp -D⟨symbol⟩[=⟨value⟩] -U⟨symbol⟩ -I⟨dir⟩
Finding imports
-i ⟨dir1⟩:⟨dir2⟩:... -i
Interactive mode
-ignore-dot-ghci -ghci-script -fbreak-on-error -fbreak-on-exception -fghci-hist-size=⟨n⟩ -fprint-evld-with-show -fprint-bind-result -fno-print-bind-contents -fno-implicit-import-qualified -interactive-print
Interface files
-ddump-hi -ddump-hi-diffs -ddump-minimal-imports --show-iface ⟨file⟩
Keeping intermediate files
-keep-hc-file, -keep-hc-files -keep-llvm-file, -keep-llvm-files -keep-s-file, -keep-s-files -keep-tmp-files
Language options
-fconstraint-solver-iterations=⟨n⟩ -freduction-depth=⟨n⟩ -fcontext-stack=⟨n⟩ -fglasgow-exts -firrefutable-tuples -fpackage-trust -ftype-function-depth=⟨n⟩ -XAllowAmbiguousTypes -XArrows -XApplicativeDo -XAutoDeriveTypeable -XBangPatterns -XBinaryLiterals -XCApiFFI -XConstrainedClassMethods -XConstraintKinds -XCPP -XDataKinds -XDefaultSignatures -XDeriveAnyClass -XDeriveDataTypeable -XDeriveFunctor -XDeriveFoldable -XDeriveGeneric -XDeriveGeneric -XDeriveLift -XDeriveTraversable -XDisambiguateRecordFields -XEmptyCase -XEmptyDataDecls -XExistentialQuantification -XExplicitForAll -XExplicitNamespaces -XExtendedDefaultRules -XFlexibleContexts -XFlexibleInstances -XForeignFunctionInterface -XFunctionalDependencies -XGADTs -XGADTSyntax -XGeneralizedNewtypeDeriving -XGenerics -XImplicitParams -XNoImplicitPrelude -XImpredicativeTypes -XIncoherentInstances -XTypeFamilyDependencies -XInstanceSigs -XInterruptibleFFI -XKindSignatures -XLambdaCase -XLiberalTypeSynonyms -XMagicHash -XMonadComprehensions -XMonoLocalBinds -XNoMonomorphismRestriction -XMultiParamTypeClasses -XMultiWayIf -XNamedFieldPuns -XNamedWildCards -XNegativeLiterals -XNoNPlusKPatterns -XNullaryTypeClasses -XNumDecimals -XOverlappingInstances -XOverloadedLists -XOverloadedStrings -XPackageImports -XParallelArrays -XParallelListComp -XPartialTypeSignatures -XPatternGuards -XPatternSynonyms -XPolyKinds -XPolymorphicComponents -XPostfixOperators -XQuasiQuotes -XRank2Types -XRankNTypes -XRebindableSyntax -XRecordWildCards -XRecursiveDo -XRoleAnnotations -XSafe -XScopedTypeVariables -XStandaloneDeriving -XStrictData -XTemplateHaskell -XTemplateHaskellQuotes -XNoTraditionalRecordSyntax -XTransformListComp -XTrustworthy -XTupleSections -XTypeFamilies -XTypeOperators -XTypeSynonymInstances -XUnboxedTuples -XUndecidableInstances -XUnicodeSyntax -XUnliftedFFITypes -XUnsafe -XViewPatterns
Linking options
-shared -staticlib -fPIC -dynload -framework⟨name⟩ -framework-path⟨name⟩ -l⟨lib⟩ -L⟨dir⟩ -main-is --mk-dll -no-hs-main -rtsopts,-rtsopts={none,some,all} -with-rtsopts=opts -no-rtsopts-suggestions -no-link -split-objs -split-sections -static -threaded -debug -ticky -eventlog -fno-gen-manifest -fno-embed-manifest -fno-shared-implib -dylib-install-name ⟨path⟩ -rdynamic
Miscellaneous options
-jN -fno-hi-version-check -fhistory-size -fno-ghci-history -fno-ghci-sandbox -freverse-errors
Modes of operation
--help,-? --interactive --make -e expr --show-iface -M --frontend ⟨module⟩ --supported-extensions, --supported-languages --show-options --info --version, -V --numeric-version --print-libdir
Individual optimizations
-fcall-arity -fcase-merge -fcmm-elim-common-blocks -fcmm-sink -fcpr-anal -fcse -fdicts-cheap -fdicts-strict -fdmd-tx-dict-sel -fdo-eta-reduction -fdo-lambda-eta-expansion -feager-blackholing -fenable-rewrite-rules -fexcess-precision -fexpose-all-unfoldings -ffloat-in -ffull-laziness -ffun-to-thunk -fignore-asserts -fignore-interface-pragmas -flate-dmd-anal -fliberate-case -fliberate-case-threshold=⟨n⟩ -floopification -fmax-inline-alloc-size=⟨n⟩ -fmax-inline-memcpy-insns=⟨n⟩ -fmax-inline-memset-insns=⟨n⟩ -fmax-relevant-binds=⟨n⟩ -fmax-simplifier-iterations=⟨n⟩ -fmax-worker-args=⟨n⟩ -fno-opt-coercion -fno-pre-inlining -fno-state-hack -fomit-interface-pragmas -fomit-yields -foptimal-applicative-do -fpedantic-bottoms -fregs-graph -fregs-iterative -fsimplifier-phases=⟨n⟩ -fsimpl-tick-factor=⟨n⟩ -fspec-constr -fspec-constr-count=⟨n⟩ -fspec-constr-threshold=⟨n⟩ -fspecialise -fcross-module-specialise -fstatic-argument-transformation -fstrictness -fstrictness-before=⟨n⟩ -funbox-small-strict-fields -funbox-strict-fields -funfolding-creation-threshold=⟨n⟩ -funfolding-dict-discount=⟨n⟩ -funfolding-fun-discount=⟨n⟩ -funfolding-keeness-factor=⟨n⟩ -funfolding-use-threshold=⟨n⟩ -fvectorisation-avoidance -fvectorise -fworker-wrapper
Optimization levels
-O0 -O, -O1 -O2 -Odph
Package options
-this-unit-id⟨P⟩ -package⟨P⟩ -hide-all-packages -hide-package⟨name⟩ -ignore-package⟨name⟩ -package-db⟨file⟩ -clear-package-db -no-global-package-db -global-package-db -no-user-package-db -user-package-db -no-auto-link-packages -trust⟨P⟩ -distrust⟨P⟩ -distrust-all
Phases of compilation
-F -E -C -S -c -x⟨suffix⟩
Overriding external programs
-pgmL⟨cmd⟩ -pgmP⟨cmd⟩ -pgmc⟨cmd⟩ -pgmlo⟨cmd⟩ -pgmlc⟨cmd⟩ -pgms⟨cmd⟩ -pgma⟨cmd⟩ -pgml⟨cmd⟩ -pgmdll⟨cmd⟩ -pgmF⟨cmd⟩ -pgmwindres⟨cmd⟩ -pgmlibtool⟨cmd⟩
Phase-specific options
-optL⟨option⟩ -optP⟨option⟩ -optF⟨option⟩ -optc⟨option⟩ -optlo⟨option⟩ -optlc⟨option⟩ -opta⟨option⟩ -optl⟨option⟩ -optdll⟨option⟩ -optwindres⟨option⟩
Platform-specific options
-msse2 -msse4.2
Compiler plugins
-fplugin=⟨module⟩ -fplugin-opt=⟨module:args⟩
-prof -fprof-auto -fprof-auto-top -fprof-auto-exported -fprof-cafs -fno-prof-count-entries -ticky
Program coverage
-fhpc -hpcdir dir
Recompilation checking
Redirecting output
-hcsuf ⟨suffix⟩ -hidir ⟨dir⟩ -hisuf ⟨suffix⟩ -o ⟨filename⟩ -odir ⟨dir⟩ -ohi ⟨filename⟩ -osuf ⟨suffix⟩ -stubdir ⟨dir⟩ -dumpdir ⟨dir⟩ -outputdir ⟨dir⟩ -dyno <filename> -dynosuf <suffix> -dynhisuf <suffix>
Temporary files
-tmpdir ⟨dir⟩
Verbosity options
-v -v⟨n⟩ -fprint-potential-instances -fprint-explicit-foralls -fprint-explicit-kinds -fprint-explicit-runtime-reps -fprint-unicode-syntax -fprint-expanded-synonyms -fprint-typechecker-elaboration -ferror-spans -Rghc-timing
-W -w -Wall -Wcompat -Werror -Wwarn -Wunrecognised-warning-flags -fshow-warning-groups -fdefer-type-errors -fdefer-typed-holes -fdefer-out-of-scope-variables -fhelpful-errors -Wdeprecated-flags -Wduplicate-constraints -Wduplicate-exports -Whi-shadowing -Widentities -Wimplicit-prelude -Wincomplete-patterns -Wincomplete-uni-patterns -Wmax-pmcheck-iterations=<N> -Wincomplete-record-updates -Wmissing-fields -Wmissing-import-lists -Wmissing-methods -Wmissing-signatures -Wmissing-exported-sigs -Wmissing-exported-signatures -Wmissing-local-sigs -Wmissing-local-signatures -Wmissing-monadfail-instances -Wsemigroup -Wmissed-specialisations -Wall-missed-specialisations -Wmonomorphism-restriction -Wname-shadowing -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances -Wnoncanonical-monoid-instances -Worphans -Woverlapping-patterns -Wtabs -Wtype-defaults -Wunrecognised-pragmas -Wunticked-promoted-constructors -Wunused-binds -Wunused-top-binds -Wunused-local-binds -Wunused-pattern-binds -Wunused-imports -Wunused-matches -Wunused-foralls -Wunused-type-variables -Wunused-do-bind -Wwrong-do-bind -Wunsafe -Wsafe -Wtrustworthy-safe -Wwarnings-deprecations -Wamp -Wredundant-constraints -Wdeferred-type-errors -Wtyped-holes -Wdeferred-out-of-scope-variables -Wpartial-type-signatures -Wderiving-typeable

Code generation

Use the native code generator
Compile using the LLVM code generator
Omit code generation
Always write interface files
Generate byte-code
Generate object code
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.
Build dynamically-linked object files and executables
Build dynamic object files as well as static object files during compilation

Debugging the compiler

Turn on internal sanity checking
Dump to files instead of stdout
Dump assembly
Dump interpreter byte code
Dump C-- output
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
Dump foreign export stubs
Dump after instrumentation for program coverage
Dump inlining info
Dump LLVM intermediate code. Implies -fllvm.
Dump occurrence analysis output
Dump the results of C-- to C-- optimising passes
Dump parse tree
Dump prepared core
Dump renamer output
Dump rule firing info
Dump detailed rule firing info
Dump rules
Dump vectoriser input and output
Dump final simplifier output
Dump output from each simplifier iteration
Dump specialiser output
Dump TH spliced expressions, and what they evaluate to
Dump final STG
Dump strictness analyser output
Dump strictness signatures
Dump typechecker output
Show evaluated TH declarations in a .th.hs file
Dump type signatures
Dump worker-wrapper output
Trace interface files
Trace typechecker
Trace vectoriser
Trace renamer
Renamer stats
Dump simplifier stats
Suppress unsolicited debugging output
Turn on debug printing (more verbose)
Set the depth for printing expressions in error msgs
Set the width of debugging output. For example -dppr-cols200
Print single alternative case expressions as strict lets.
In core dumps, suppress everything (except for uniques) that is suppressible.
Suppress the printing of uniques in debug output (easier to use diff)
Suppress extended information about identifiers where they are bound
Suppress the printing of the stable unfolding of a variable at its binding site
Suppress the printing of module qualification prefixes
Suppress type signatures
Suppress type applications
Suppress the printing of coercions in Core dumps to make them shorter
Dump haskell source stats
C-- pass sanity checking
STG pass sanity checking
Dump STG stats
Show output from each core-to-core pass
Show output from each STG-to-STG pass
Print out each pass name as it happens
Show statistics for fast string usage when finished
Report sites with rules that could have fired but didn't. Takes a string argument.

C pre-processor

Run the C pre-processor on Haskell source files
Define a symbol in the C pre-processor
Undefine a symbol in the C pre-processor
Add ⟨dir⟩ to the directory search list for #include files

Finding imports

-i ⟨dir1⟩:⟨dir2⟩:...
add ⟨dir⟩, ⟨dir2⟩, etc. to import path
Empty the import directory list

Interactive mode

Disable reading of .ghci files
Read additional .ghci files
Break on uncaught exceptions and errors
Break on any exception thrown
Set the number of entries GHCi keeps for :history. See ghci-debugger.
Enable usage of Show instances in :print. See breakpoints.
Turn on printing of binding results in GHCi
Turn off printing of binding contents in GHCi
Turn off implicit qualified import of everything in GHCi
Select the function to use for printing evaluated expressions in GHCi

Interface files

Dump the new interface to stdout
Show the differences vs. the old interface
Dump a minimal set of imports
--show-iface ⟨file⟩
See modes.

Keeping intermediate files

-keep-hc-file, -keep-hc-files
Retain intermediate .hc files.
-keep-llvm-file, -keep-llvm-files
Retain intermediate LLVM .ll files. Implies -fllvm.
-keep-s-file, -keep-s-files
Retain intermediate .s files.
Retain all intermediate temporary files.

Language options

default: 4. Set the iteration limit for the type-constraint solver. Typically one iteration suffices; so please yell if you find you need to set it higher than the default. Zero means infinity.
default: 200. Set the limit for type simplification. Zero means infinity.
Deprecated. Use -freduction-depth=⟨n⟩ instead.
Deprecated. Enable most language extensions; see options-language for exactly which ones.
Make tuple pattern matching irrefutable
Enable Safe Haskell trusted package requirement for trustworthy modules.
Deprecated. Use -freduction-depth=⟨n⟩ instead.
Allow the user to write ambiguous types, and the type inference engine to infer them.
Enable arrow notation extension
Enable Applicative do-notation desugaring
As of GHC 7.10, this option is not needed, and should not be used. Previously this would automatically derive Typeable instances for every datatype and type class declaration. Implies -XDeriveDataTypeable.
Enable bang patterns.
Enable support for binary literals.
Enable the CAPI calling convention.
Enable constrained class methods.
Enable a kind of constraints.
Enable the C preprocessor.
Enable datatype promotion.
Enable default signatures.
Enable deriving for any class.
Enable deriving for the Data class. Implied by -XAutoDeriveTypeable.
Enable deriving for the Functor class. Implied by -XDeriveTraversable.
Enable deriving for the Foldable class. Implied by -XDeriveTraversable.
Enable deriving for the Generic class.
Enable deriving for the Generic class.
Enable deriving for the Lift class
Enable deriving for the Traversable class. Implies -XDeriveFunctor and -XDeriveFoldable.
Enable record field disambiguation. Implied by -XRecordWildCards.
Allow empty case alternatives.
Enable empty data declarations.
Enable existential quantification.
Enable explicit universal quantification. Implied by -XScopedTypeVariables, -XLiberalTypeSynonyms, -XRankNTypes and -XExistentialQuantification.
Enable using the keyword type to specify the namespace of entries in imports and exports (explicit-namespaces). Implied by -XTypeOperators and -XTypeFamilies.
Use GHCi's extended default rules in a normal module.
Enable flexible contexts. Implied by -XImplicitParams.
Enable flexible instances. Implies -XTypeSynonymInstances. Implied by -XImplicitParams.
Enable foreign function interface.
Enable functional dependencies. Implies -XMultiParamTypeClasses.
Enable generalised algebraic data types. Implies -XGADTSyntax and -XMonoLocalBinds.
Enable generalised algebraic data type syntax.
Enable newtype deriving.
Deprecated, does nothing. No longer enables generic classes. See also GHC's support for generic programming.
Enable Implicit Parameters. Implies -XFlexibleContexts and -XFlexibleInstances.
Don't implicitly import Prelude. Implied by -XRebindableSyntax.
Enable impredicative types. Implies -XRankNTypes.
Enable incoherent instances. Implies -XOverlappingInstances.
Enable injective type families. Implies -XTypeFamilies.
Enable instance signatures.
Enable interruptible FFI.
Enable kind signatures. Implied by -XTypeFamilies and -XPolyKinds.
Enable lambda-case expressions.
Enable liberalised type synonyms.
Allow # as a postfix modifier on identifiers.
Enable monad comprehensions.
Enable do not generalise local bindings. Implied by -XTypeFamilies and -XGADTs.
Disable the monomorphism restriction.
Enable multi parameter type classes. Implied by -XFunctionalDependencies.
Enable multi-way if-expressions.
Enable record puns.
Enable named wildcards.
Enable support for negative literals.
Disable support for n+k patterns.
Deprecated, does nothing. nullary (no parameter) type classes are now enabled using -XMultiParamTypeClasses.
Enable support for 'fractional' integer literals.
Enable overlapping instances.
Enable overloaded lists.
Enable overloaded string literals.
Enable package-qualified imports.
Enable parallel arrays. Implies -XParallelListComp.
Enable parallel list comprehensions. Implied by -XParallelArrays.
Enable partial type signatures.
Enable pattern guards.
Enable pattern synonyms.
Enable kind polymorphism. Implies -XKindSignatures.
Enable polymorphic components for data constructors. Synonym for -XRankNTypes.
Enable postfix operators.
Enable quasiquotation.
Enable rank-2 types. Synonym for -XRankNTypes.
Enable rank-N types. Implied by -XImpredicativeTypes.
Employ rebindable syntax. Implies -XNoImplicitPrelude.
Enable record wildcards. Implies -XDisambiguateRecordFields.
Enable recursive do (mdo) notation.
Enable role annotations.
Enable the Safe Haskell Safe mode.
Enable lexically-scoped type variables.
Enable standalone deriving.
Enable default strict datatype fields.
Enable Template Haskell.
Enable quotation subset of Template Haskell.
Disable support for traditional record syntax (as supported by Haskell 98) C {f = x}
Enable generalised list comprehensions.
Enable the Safe Haskell Trustworthy mode.
Enable tuple sections.
Enable type families. Implies -XExplicitNamespaces, -XKindSignatures, and -XMonoLocalBinds.
Enable type operators. Implies -XExplicitNamespaces.
Enable type synonyms in instance heads. Implied by -XFlexibleInstances.
Enable unboxed tuples.
Enable undecidable instances.
Enable unicode syntax.
Enable unlifted FFI types.
Enable Safe Haskell Unsafe mode.
Enable view patterns.

Linking options

Generate a shared library (as opposed to an executable)
On Darwin/OS X/iOS only, generate a standalone static library (as opposed to an executable). This is the usual way to compile for iOS.
Generate position-independent code (where available)
Selects one of a number of modes for finding shared libraries at runtime.
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.
Link in library ⟨lib⟩
Add ⟨dir⟩ to the list of directories searched for libraries
Set main module and function
DLL-creation mode (Windows only)
Don't assume this program contains main
Control whether the RTS behaviour can be tweaked via command-lineflags 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), and all (or no argument at all) means that all RTS flags are permitted.
Set the default RTS options to ⟨opts⟩.
Don't print RTS suggestions about linking with -rtsopts.
Omit linking
Split objects (for libraries)
Split sections for link-time dead-code stripping
Use static Haskell libraries
Use the threaded runtime
Use the debugging runtime
For linking, this simply implies -debug; see ticky-ticky.
Enable runtime event tracing
Do not generate a manifest file (Windows only)
Do not embed the manifest in the executable (Windows only)
Don't generate an import library for a DLL (Windows only)
-dylib-install-name ⟨path⟩
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)
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.

Miscellaneous options

When compiling with --make, compile ⟨N⟩ modules in parallel.
Don't complain about .hi file mismatches
Set simplification history size
Do not use the load/store the GHCi command history from/to ghci_history.
Turn off the GHCi sandbox. Means computations are run in the main thread, rather than a forked thread.
Display errors in GHC/GHCi sorted by reverse order of source code line numbers.

Modes of operation

Display help
Interactive mode - normally used by just running ghci; see ghci for details.
Build a multi-module Haskell program, automatically figuring out dependencies. Likely to be much easier, and faster, than using make; see make-mode for details.
-e expr
Evaluate expr; see eval-mode for details.
display the contents of an interface file.
generate dependency information suitable for use in a Makefile; see makefile-dependencies for details.
--frontend ⟨module⟩
run GHC with the given frontend plugin; see frontend_plugins for details.
--supported-extensions, --supported-languages
display the supported language extensions
display the supported command line options
display information about the compiler
--version, -V
display GHC version
display GHC version (numeric only)
display GHC library directory

Individual optimizations

Enable call-arity optimisation. 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.
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
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
Turn on the liberate-case transformation. Implied by -O2.
default: 2000. Set the size threshold for the liberate-case transformation to ⟨n⟩
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). GHC will allocate non-pinned arrays of statically known size in the current nursery block if they're no bigger than ⟨n⟩ bytes, ignoring GC overheap. This value should be quite a bit smaller than the block size (typically: 4096).
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: 6. Set the maximum number of bindings to display in type error messages.
default: 4. Set the max iterations for the simplifier.
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 hack" whereby 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: 2. Set the number of phases for the simplifier. Ignored with -O0.
default: 100. Set the percentage factor for simplifier ticks.
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.
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 imported from other modules.
Turn on the static argument transformation.
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.
Enable vectorisation avoidance. Always enabled by default.
Enable vectorisation of nested data parallelism
Enable the worker-wrapper transformation after a strictness analysis pass. Implied by -O, and by -fstrictness. Disabled by -fno-strictness. Enabling -fworker-wrapper while strictness analysis is disabled (by -fno-strictness) has no effect.

Optimization levels

Disable optimisations (default)
-O, -O1
Enable level 1 optimisations
Enable level 2 optimisations
Enable level 2 optimisations, set -fmax-simplifier-iterations=20 and -fsimplifier-phases=3.

Package options

Compile to be part of unit (i.e. package) ⟨P⟩
Expose package ⟨P⟩
Hide all packages by default
Hide package ⟨P⟩
Ignore package ⟨P⟩
Add ⟨file⟩ to the package db stack.
Clear the package db stack.
Remove the global package db from the stack.
Add the global package db to the stack.
Remove the user's package db from the stack.
Add the user's package db to the stack.
Don't automatically link in the base and rts packages.
Expose package ⟨P⟩ and set it to be trusted
Expose package ⟨P⟩ and set it to be distrusted
Distrust all packages by default

Phases of compilation

Enable the use of a pre-processor (set with -pgmF)
Stop after preprocessing (.hspp file)
Stop after generating C (.hc file)
Stop after generating assembly (.s file)
Stop after generating object (.o) file
Override default behaviour for source files

Overriding external programs

Use ⟨cmd⟩ as the literate pre-processor
Use ⟨cmd⟩ as the C pre-processor (with -cpp only)
Use ⟨cmd⟩ as the C compiler
Use ⟨cmd⟩ as the LLVM optimiser
Use ⟨cmd⟩ as the LLVM compiler
Use ⟨cmd⟩ as the splitter
Use ⟨cmd⟩ as the assembler
Use ⟨cmd⟩ as the linker
Use ⟨cmd⟩ as the DLL generator
Use ⟨cmd⟩ as the pre-processor (with -F only)
Use ⟨cmd⟩ as the program for embedding manifests on Windows.
Use ⟨cmd⟩ as the command for libtool (with -staticlib only).

Phase-specific options

pass ⟨option⟩ to the literate pre-processor
pass ⟨option⟩ to cpp (with -cpp only)
pass ⟨option⟩ to the custom pre-processor
pass ⟨option⟩ to the C compiler
pass ⟨option⟩ to the LLVM optimiser
pass ⟨option⟩ to the LLVM compiler
pass ⟨option⟩ to the assembler
pass ⟨option⟩ to the linker
pass ⟨option⟩ to the DLL generator
pass ⟨option⟩ to windres.

Platform-specific options

(x86 only) Use SSE2 for floating-point operations
(x86 only) Use SSE4.2 for floating-point operations

Compiler plugins

Load a plugin exported by a given module
Give arguments to a plugin module; module must be specified with -fplugin


Turn on profiling
Auto-add SCCs to all bindings not marked INLINE
Auto-add SCCs to all top-level bindings not marked INLINE
Auto-add SCCs to all exported bindings not marked INLINE
Auto-add SCCs to all CAFs
Do not collect entry counts
Turn on ticky-ticky profiling

Program coverage

Turn on Haskell program coverage instrumentation
-hpcdir dir
Directory to deposit .mix files during compilation (default is .hpc)

Recompilation checking

Turn off recompilation checking. This is implied by any -ddump-X option when compiling a single file (i.e. when using -c).

Redirecting output

-hcsuf ⟨suffix⟩
set the suffix to use for intermediate C files
-hidir ⟨dir⟩
set directory for interface files
-hisuf ⟨suffix⟩
set the suffix to use for interface files
-o ⟨filename⟩
set output filename
-odir ⟨dir⟩
set directory for object files
-ohi ⟨filename⟩
set the filename in which to put the interface
-osuf ⟨suffix⟩
set the output file suffix
-stubdir ⟨dir⟩
redirect FFI stub files
-dumpdir ⟨dir⟩
redirect dump files
-outputdir ⟨dir⟩
set output directory
-dyno <filename>
Set the output filename for dynamic object files (see -dynamic-too)
-dynosuf <suffix>
Set the object suffix for dynamic object files (see -dynamic-too)
-dynhisuf <suffix>
Set the hi suffix for dynamic object files (see -dynamic-too)

Temporary files

-tmpdir ⟨dir⟩
set the directory for temporary files

Verbosity options

verbose mode (equivalent to -v3)
set verbosity level
display all available instances in type error messages
Print explicit forall quantification in types. See also -XExplicitForAll
Print explicit kind foralls and kind arguments in types. See also -XKindSignature
Print RuntimeRep variables in types which are runtime-representation polymorphic.
Use unicode syntax when printing expressions, types and kinds. See also -XUnicodeSyntax
In type errors, also print type-synonym-expanded types.
Print extra information from typechecker.
Output full span in error messages
Summarise timing stats for GHC (same as +RTS -tstderr).


enable normal warnings
disable all warnings
enable almost all warnings (details in options-sanity)
enable future compatibility warnings (details in options-sanity)
make warnings fatal
make warnings non-fatal
throw a warning when an unreconised -W... flag is encountered on the command line.
show which group an emitted warning belongs to.
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.
Convert variable out of scope variables errors into warnings. Implied by -fdefer-type-errors. See also -Wdeferred-out-of-scope-variables.
Make suggestions for mis-spelled names.
warn about uses of commandline flags that are deprecated
warn when a constraint appears duplicated in a type signature
warn when an entity is exported multiple times
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 the Prelude is implicitly imported
warn when a pattern match could fail
warn when a pattern match in a lambda expression or pattern binding could fail
the iteration limit for the pattern match checker
warn when a record update could fail
warn when fields of a record are uninitialised
warn when an import declaration does not explicitly list all thenames brought into scope
warn when class methods are undefined
warn about top-level functions without signatures
(deprecated) warn about top-level functions without signatures, only if they are exported. takes precedence over -Wmissing-signatures
warn about top-level functions without signatures, only if they are exported. takes precedence over -Wmissing-signatures
(deprecated) warn about polymorphic local bindings without signatures
warn about polymorphic local bindings without signatures
warn when a failable pattern is used in a do-block that does not have a MonadFail instance.
warn when a Monoid is not Semigroup, and on non- Semigroup definitions of (<>)?
warn when specialisation of an imported, overloaded function fails.
warn when specialisation of any overloaded function fails.
warn when the Monomorphism Restriction is applied
warn when names are shadowed
warn when Applicative or Monad instances have noncanonical definitions of return, pure, (>>), or (*>). See flag description in options-sanity for more details.
warn when Monad or MonadFail instances have noncanonical definitions of fail.See flag description in options-sanity for more details.
warn when Semigroup or Monoid instances have noncanonical definitions of (<>) or mappend. See flag description in options-sanity for more details.
warn when the module contains orphan instance declarations or rewrite rules
warn about overlapping patterns
warn if there are tabs in the source file
warn when defaulting happens
warn about uses of pragmas that GHC doesn't recognise
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 top-level bindings that are unused
warn about local bindings that are unused
warn about pattern match bindings that are unused
warn about unnecessary imports
warn about variables in patterns that aren't used
warn about type variables in user-written foralls that are unused
warn about variables in type family or data family instances that are unused
warn about do bindings that appear to throw away values of types other than ()
warn about do bindings that appear to throw away monadic values that you should have bound instead
warn if the module being compiled is regarded to be unsafe. Should be used to check the safety status of modules when using safe inference. Works on all module types, even those using explicit Safe Haskell modes (such as -XTrustworthy) and so can be used to have the compiler check any assumptions made.
warn if the module being compiled is regarded to be safe. Should be used to check the safety status of modules when using safe inference. Works on all module types, even those using explicit Safe Haskell modes (such as -XTrustworthy) and so can be used to have the compiler check any assumptions made.
warn if the module being compiled is marked as -XTrustworthy but it could instead be marked as -XSafe, a more informative bound. Can be used to detectonce a Safe Haskell bound can be improved as dependencies are updated.
warn about uses of functions & types that have warnings or deprecated pragmas
(deprecated) warn on definitions conflicting with the Applicative-Monad Proposal (AMP)
Have the compiler warn about redundant constraints in typesignatures.
Report warnings when deferred type errors are enabled. This option is enabled by default. See -fdefer-type-errors.
Report warnings when typed hole errors are deferred until runtime. See -fdefer-typed-holes.
Report warnings when variable out-of-scope errors are deferred until runtime. See -fdefer-out-of-scope-variables.
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.
warn when encountering a request to derive an instance of class Typeable. As of GHC 7.10, such declarations are unnecessary and are ignored by the compiler because GHC has a custom solver for discharging this type of constraint.

Copyright 2015. The University Court of the University of Glasgow. All rights reserved.


The GHC Team 2017, GHC Team
August 29, 2017 8.0.2