7.6. Flag reference

This section is a quick-reference for GHC’s command-line flags. For each flag, we also list its static/dynamic status (see Static, Dynamic, and Mode options), and the flag’s opposite (if available).

7.6.1. Verbosity options

More details in Verbosity options

Flag Description Static/Dynamic Reverse
-v verbose mode (equivalent to -v3) dynamic  
-v⟨n⟩ set verbosity level dynamic  
-fprint-potential-instances display all available instances in type error messages dynamic -fno-print-potential-instances
-fprint-explicit-foralls Print explicit forall quantification in types. See also -XExplicitForAll dynamic -fno-print-explicit-foralls
-fprint-explicit-kinds Print explicit kind foralls and kind arguments in types. See also -XKindSignature dynamic -fno-print-explicit-kinds
-fprint-explicit-runtime-reps Print RuntimeRep variables in types which are runtime-representation polymorphic. dynamic -fno-print-explicit-runtime-reps
-fprint-unicode-syntax Use unicode syntax when printing expressions, types and kinds. See also -XUnicodeSyntax dynamic -fno-print-unicode-syntax
-fprint-expanded-synonyms In type errors, also print type-synonym-expanded types. dynamic -fno-print-expanded-synonyms
-fprint-typechecker-elaboration Print extra information from typechecker. dynamic -fno-print-typechecker-elaboration
-ferror-spans Output full span in error messages dynamic  
-Rghc-timing Summarise timing stats for GHC (same as +RTS -tstderr). dynamic  

7.6.2. Alternative modes of operation

More details in Modes of operation

Flag Description Static/Dynamic Reverse
--help,-? Display help mode  
--interactive Interactive mode - normally used by just running ghci; see GHCiを使う for details. mode  
--make 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. mode  
-e expr Evaluate expr; see Expression evaluation mode for details. mode  
--show-iface display the contents of an interface file. mode  
-M generate dependency information suitable for use in a Makefile; see Dependency generation for details. mode  
--frontend ⟨module⟩ run GHC with the given frontend plugin; see Frontend plugins for details. mode  
--supported-extensions, --supported-languages display the supported language extensions mode  
--show-options display the supported command line options mode  
--info display information about the compiler mode  
--version, -V display GHC version mode  
--numeric-version display GHC version (numeric only) mode  
--print-libdir display GHC library directory mode  

7.6.3. Which phases to run

More details in Batch compiler mode

Flag Description Static/Dynamic Reverse
-F Enable the use of a pre-processor (set with -pgmF) dynamic  
-E Stop after preprocessing (.hspp file) mode  
-C Stop after generating C (.hc file) mode  
-S Stop after generating assembly (.s file) mode  
-c Stop after generating object (.o) file mode  
-x⟨suffix⟩ Override default behaviour for source files dynamic  

7.6.4. Redirecting output

More details in Redirecting the compilation output(s)

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

7.6.5. Keeping intermediate files

More details in Keeping Intermediate Files

Flag Description Static/Dynamic Reverse
-keep-hc-file, -keep-hc-files Retain intermediate .hc files. dynamic  
-keep-llvm-file, -keep-llvm-files Retain intermediate LLVM .ll files. Implies -fllvm. dynamic  
-keep-s-file, -keep-s-files Retain intermediate .s files. dynamic  
-keep-tmp-files Retain all intermediate temporary files. dynamic  

7.6.6. Temporary files

More details in Redirecting temporary files

Flag Description Static/Dynamic Reverse
-tmpdir ⟨dir⟩ set the directory for temporary files dynamic  

7.6.7. Finding imports

More details in The search path

Flag Description Static/Dynamic Reverse
-i ⟨dir1⟩:⟨dir2⟩:... add ⟨dir⟩, ⟨dir2⟩, etc. to import path dynamic/:set  
-i Empty the import directory list dynamic/:set  

7.6.8. Interface file options

More details in Other options related to interface files

Flag Description Static/Dynamic Reverse
-ddump-hi Dump the new interface to stdout dynamic  
-ddump-hi-diffs Show the differences vs. the old interface dynamic  
-ddump-minimal-imports Dump a minimal set of imports dynamic  
--show-iface ⟨file⟩ See Modes of operation. mode  

7.6.9. Recompilation checking

More details in The recompilation checker

Flag Description Static/Dynamic Reverse
-fforce-recomp Turn off recompilation checking. This is implied by any -ddump-X option when compiling a single file (i.e. when using -c). dynamic -fno-force-recomp

7.6.10. Interactive-mode options

More details in The .ghci and .haskeline files

Flag Description Static/Dynamic Reverse
-ignore-dot-ghci Disable reading of .ghci files dynamic  
-ghci-script Read additional .ghci files dynamic  
-fbreak-on-error Break on uncaught exceptions and errors dynamic -fno-break-on-error
-fbreak-on-exception Break on any exception thrown dynamic -fno-break-on-exception
-fghci-hist-size=⟨n⟩ Set the number of entries GHCi keeps for :history. See GHCiのデバッガ. dynamic (default is 50)
-fprint-evld-with-show Enable usage of Show instances in :print. See ブレイクポイントと変数内容の表示. dynamic -fno-print-evld-with-show
-fprint-bind-result Turn on printing of binding results in GHCi dynamic -fno-print-bind-result
-fno-print-bind-contents Turn off printing of binding contents in GHCi dynamic  
-fno-implicit-import-qualified Turn off implicit qualified import of everything in GHCi dynamic  
-interactive-print Select the function to use for printing evaluated expressions in GHCi dynamic  

7.6.11. Packages

More details in Packages

Flag Description Static/Dynamic Reverse
-this-unit-id⟨P⟩ Compile to be part of unit (i.e. package) ⟨P⟩ dynamic  
-package⟨P⟩ Expose package ⟨P⟩ dynamic/:set  
-hide-all-packages Hide all packages by default dynamic  
-hide-package⟨name⟩ Hide package ⟨P⟩ dynamic/:set  
-ignore-package⟨name⟩ Ignore package ⟨P⟩ dynamic/:set  
-package-db⟨file⟩ Add ⟨file⟩ to the package db stack. dynamic  
-clear-package-db Clear the package db stack. dynamic  
-no-global-package-db Remove the global package db from the stack. dynamic  
-global-package-db Add the global package db to the stack. dynamic  
-no-user-package-db Remove the user’s package db from the stack. dynamic  
-user-package-db Add the user’s package db to the stack. dynamic  
-no-auto-link-packages Don’t automatically link in the base and rts packages. dynamic  
-trust⟨P⟩ Expose package ⟨P⟩ and set it to be trusted dynamic/:set  
-distrust⟨P⟩ Expose package ⟨P⟩ and set it to be distrusted dynamic/:set  
-distrust-all Distrust all packages by default dynamic/:set  

7.6.12. Language options

Language options can be enabled either by a command-line option -Xblah, or by a {-# LANGUAGE blah #-} pragma in the file itself. See Language options. Some options are enabled using -f* flags.

Flag Description Static/Dynamic Reverse
-fconstraint-solver-iterations=⟨n⟩ 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. dynamic  
-freduction-depth=⟨n⟩ default: 200. Set the limit for type simplification. Zero means infinity. dynamic  
-fcontext-stack=⟨n⟩ Deprecated. Use -freduction-depth=⟨n⟩ instead. dynamic  
-fglasgow-exts Deprecated. Enable most language extensions; see Language options for exactly which ones. dynamic -fno-glasgow-exts
-firrefutable-tuples Make tuple pattern matching irrefutable dynamic -fno-irrefutable-tuples
-fpackage-trust Enable Safe Haskell trusted package requirement for trustworthy modules. dynamic  
-ftype-function-depth=⟨n⟩ Deprecated. Use -freduction-depth=⟨n⟩ instead. dynamic  
-XAllowAmbiguousTypes Allow the user to write ambiguous types, and the type inference engine to infer them. dynamic -XNoAllowAmbiguousTypes
-XArrows Enable arrow notation extension dynamic -XNoArrows
-XApplicativeDo Enable Applicative do-notation desugaring dynamic -XNoApplicativeDo
-XAutoDeriveTypeable 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. dynamic -XNoAutoDeriveTypeable
-XBangPatterns Enable bang patterns. dynamic -XNoBangPatterns
-XBinaryLiterals Enable support for binary literals. dynamic -XNoBinaryLiterals
-XCApiFFI Enable the CAPI calling convention. dynamic -XNoCAPIFFI
-XConstrainedClassMethods Enable constrained class methods. dynamic -XNoConstrainedClassMethods
-XConstraintKinds Enable a kind of constraints. dynamic -XNoConstraintKinds
-XCPP Enable the C preprocessor. dynamic -XNoCPP
-XDataKinds Enable datatype promotion. dynamic -XNoDataKinds
-XDefaultSignatures Enable default signatures. dynamic -XNoDefaultSignatures
-XDeriveAnyClass Enable deriving for any class. dynamic -XNoDeriveAnyClass
-XDeriveDataTypeable Enable deriving for the Data class. Implied by -XAutoDeriveTypeable. dynamic -XNoDeriveDataTypeable
-XDeriveFunctor Enable deriving for the Functor class. Implied by -XDeriveTraversable. dynamic -XNoDeriveFunctor
-XDeriveFoldable Enable deriving for the Foldable class. Implied by -XDeriveTraversable. dynamic -XNoDeriveFoldable
-XDeriveGeneric Enable deriving for the Generic class. dynamic -XNoDeriveGeneric
-XDeriveGeneric Enable deriving for the Generic class. dynamic -XNoDeriveGeneric
-XDeriveLift Enable deriving for the Lift class dynamic -XNoDeriveLift
-XDeriveTraversable Enable deriving for the Traversable class. Implies -XDeriveFunctor and -XDeriveFoldable. dynamic -XNoDeriveTraversable
-XDisambiguateRecordFields Enable record field disambiguation. Implied by -XRecordWildCards. dynamic -XNoDisambiguateRecordFields
-XEmptyCase Allow empty case alternatives. dynamic -XNoEmptyCase
-XEmptyDataDecls Enable empty data declarations. dynamic -XNoEmptyDataDecls
-XExistentialQuantification Enable existential quantification. dynamic -XNoExistentialQuantification
-XExplicitForAll Enable explicit universal quantification. Implied by -XScopedTypeVariables, -XLiberalTypeSynonyms, -XRankNTypes and -XExistentialQuantification. dynamic -XNoExplicitForAll
-XExplicitNamespaces Enable using the keyword type to specify the namespace of entries in imports and exports (Explicit namespaces in import/export). Implied by -XTypeOperators and -XTypeFamilies. dynamic -XNoExplicitNamespaces
-XExtendedDefaultRules Use GHCi’s extended default rules in a normal module. dynamic -XNoExtendedDefaultRules
-XFlexibleContexts Enable flexible contexts. Implied by -XImplicitParams. dynamic -XNoFlexibleContexts
-XFlexibleInstances Enable flexible instances. Implies -XTypeSynonymInstances. Implied by -XImplicitParams. dynamic -XNoFlexibleInstances
-XForeignFunctionInterface Enable foreign function interface. dynamic -XNoForeignFunctionInterface
-XFunctionalDependencies Enable functional dependencies. Implies -XMultiParamTypeClasses. dynamic -XNoFunctionalDependencies
-XGADTs Enable generalised algebraic data types. Implies -XGADTSyntax and -XMonoLocalBinds. dynamic -XNoGADTs
-XGADTSyntax Enable generalised algebraic data type syntax. dynamic -XNoGADTSyntax
-XGeneralizedNewtypeDeriving Enable newtype deriving. dynamic -XNoGeneralizedNewtypeDeriving
-XGenerics Deprecated, does nothing. No longer enables generic classes. See also GHC’s support for generic programming. dynamic -XNoGenerics
-XImplicitParams Enable Implicit Parameters. Implies -XFlexibleContexts and -XFlexibleInstances. dynamic -XNoImplicitParams
-XNoImplicitPrelude Don’t implicitly import Prelude. Implied by -XRebindableSyntax. dynamic -XImplicitPrelude
-XImpredicativeTypes Enable impredicative types. Implies -XRankNTypes. dynamic -XNoImpredicativeTypes
-XIncoherentInstances Enable incoherent instances. Implies -XOverlappingInstances. dynamic -XNoIncoherentInstances
-XTypeFamilyDependencies Enable injective type families. Implies -XTypeFamilies. dynamic -XNoTypeFamilyDependencies
-XInstanceSigs Enable instance signatures. dynamic -XNoInstanceSigs
-XInterruptibleFFI Enable interruptible FFI. dynamic -XNoInterruptibleFFI
-XKindSignatures Enable kind signatures. Implied by -XTypeFamilies and -XPolyKinds. dynamic -XNoKindSignatures
-XLambdaCase Enable lambda-case expressions. dynamic -XNoLambdaCase
-XLiberalTypeSynonyms Enable liberalised type synonyms. dynamic -XNoLiberalTypeSynonyms
-XMagicHash Allow # as a postfix modifier on identifiers. dynamic -XNoMagicHash
-XMonadComprehensions Enable monad comprehensions. dynamic -XNoMonadComprehensions
-XMonoLocalBinds Enable do not generalise local bindings. Implied by -XTypeFamilies and -XGADTs. dynamic -XNoMonoLocalBinds
-XNoMonomorphismRestriction Disable the monomorphism restriction. dynamic -XMonomorphismRestriction
-XMultiParamTypeClasses Enable multi parameter type classes. Implied by -XFunctionalDependencies. dynamic -XNoMultiParamTypeClasses
-XMultiWayIf Enable multi-way if-expressions. dynamic -XNoMultiWayIf
-XNamedFieldPuns Enable record puns. dynamic -XNoNamedFieldPuns
-XNamedWildCards Enable named wildcards. dynamic -XNoNamedWildCards
-XNegativeLiterals Enable support for negative literals. dynamic -XNoNegativeLiterals
-XNoNPlusKPatterns Disable support for n+k patterns. dynamic -XNPlusKPatterns
-XNullaryTypeClasses Deprecated, does nothing. nullary (no parameter) type classes are now enabled using -XMultiParamTypeClasses. dynamic -XNoNullaryTypeClasses
-XNumDecimals Enable support for ‘fractional’ integer literals. dynamic -XNoNumDecimals
-XOverlappingInstances Enable overlapping instances. dynamic -XNoOverlappingInstances
-XOverloadedLists Enable overloaded lists. dynamic -XNoOverloadedLists
-XOverloadedStrings Enable overloaded string literals. dynamic -XNoOverloadedStrings
-XPackageImports Enable package-qualified imports. dynamic -XNoPackageImports
-XParallelArrays Enable parallel arrays. Implies -XParallelListComp. dynamic -XNoParallelArrays
-XParallelListComp Enable parallel list comprehensions. Implied by -XParallelArrays. dynamic -XNoParallelListComp
-XPartialTypeSignatures Enable partial type signatures. dynamic -XNoPartialTypeSignatures
-XPatternGuards Enable pattern guards. dynamic -XNoPatternGuards
-XPatternSynonyms Enable pattern synonyms. dynamic -XNoPatternSynonyms
-XPolyKinds Enable kind polymorphism. Implies -XKindSignatures. dynamic -XNoPolyKinds
-XPolymorphicComponents Enable polymorphic components for data constructors. Synonym for -XRankNTypes. dynamic -XNoPolymorphicComponents
-XPostfixOperators Enable postfix operators. dynamic -XNoPostfixOperators
-XQuasiQuotes Enable quasiquotation. dynamic -XNoQuasiQuotes
-XRank2Types Enable rank-2 types. Synonym for -XRankNTypes. dynamic -XNoRank2Types
-XRankNTypes Enable rank-N types. Implied by -XImpredicativeTypes. dynamic -XNoRankNTypes
-XRebindableSyntax Employ rebindable syntax. Implies -XNoImplicitPrelude. dynamic -XNoRebindableSyntax
-XRecordWildCards Enable record wildcards. Implies -XDisambiguateRecordFields. dynamic -XNoRecordWildCards
-XRecursiveDo Enable recursive do (mdo) notation. dynamic -XNoRecursiveDo
-XRoleAnnotations Enable role annotations. dynamic -XNoRoleAnnotations
-XSafe Enable the Safe Haskell Safe mode. dynamic  
-XScopedTypeVariables Enable lexically-scoped type variables. dynamic -XNoScopedTypeVariables
-XStandaloneDeriving Enable standalone deriving. dynamic -XNoStandaloneDeriving
-XStrictData Enable default strict datatype fields. dynamic -XNoStrictData
-XTemplateHaskell Enable Template Haskell. dynamic -XNoTemplateHaskell
-XTemplateHaskellQuotes Enable quotation subset of Template Haskell. dynamic -XNoTemplateHaskellQuotes
-XNoTraditionalRecordSyntax Disable support for traditional record syntax (as supported by Haskell 98) C {f = x} dynamic -XTraditionalRecordSyntax
-XTransformListComp Enable generalised list comprehensions. dynamic -XNoTransformListComp
-XTrustworthy Enable the Safe Haskell Trustworthy mode. dynamic  
-XTupleSections Enable tuple sections. dynamic -XNoTupleSections
-XTypeFamilies Enable type families. Implies -XExplicitNamespaces, -XKindSignatures, and -XMonoLocalBinds. dynamic -XNoTypeFamilies
-XTypeOperators Enable type operators. Implies -XExplicitNamespaces. dynamic -XNoTypeOperators
-XTypeSynonymInstances Enable type synonyms in instance heads. Implied by -XFlexibleInstances. dynamic -XNoTypeSynonymInstances
-XUnboxedTuples Enable unboxed tuples. dynamic -XNoUnboxedTuples
-XUndecidableInstances Enable undecidable instances. dynamic -XNoUndecidableInstances
-XUnicodeSyntax Enable unicode syntax. dynamic -XNoUnicodeSyntax
-XUnliftedFFITypes Enable unlifted FFI types. dynamic -XNoUnliftedFFITypes
-XUnsafe Enable Safe Haskell Unsafe mode. dynamic  
-XViewPatterns Enable view patterns. dynamic -XNoViewPatterns

7.6.13. Warnings

More details in Warnings and sanity-checking

Flag Description Static/Dynamic Reverse
-W enable normal warnings dynamic -w
-w disable all warnings dynamic  
-Wall enable almost all warnings (details in Warnings and sanity-checking) dynamic -w
-Wcompat enable future compatibility warnings (details in Warnings and sanity-checking) dynamic -Wno-compat
-Werror make warnings fatal dynamic -Wwarn
-Wwarn make warnings non-fatal dynamic -Werror
-Wunrecognised-warning-flags throw a warning when an unreconised -W... flag is encountered on the command line. dynamic -Wno-unrecognised-warning-flags
-fshow-warning-groups show which group an emitted warning belongs to. dynamic -fno-show-warning-groups
-fdefer-type-errors 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 dynamic -fno-defer-type-errors
-fdefer-typed-holes Convert typed hole errors into warnings, deferring the error until runtime. Implied by -fdefer-type-errors. See also -Wtyped-holes. dynamic -fno-defer-typed-holes
-fdefer-out-of-scope-variables Convert variable out of scope variables errors into warnings. Implied by -fdefer-type-errors. See also -Wdeferred-out-of-scope-variables. dynamic -fno-defer-out-of-scope-variables
-fhelpful-errors Make suggestions for mis-spelled names. dynamic -fno-helpful-errors
-Wdeprecated-flags warn about uses of commandline flags that are deprecated dynamic -Wno-deprecated-flags
-Wduplicate-constraints warn when a constraint appears duplicated in a type signature dynamic -Wno-duplicate-constraints
-Wduplicate-exports warn when an entity is exported multiple times dynamic -Wno-duplicate-exports
-Whi-shadowing warn when a .hi file in the current directory shadows a library dynamic -Wno-hi-shadowing
-Widentities warn about uses of Prelude numeric conversions that are probably the identity (and hence could be omitted) dynamic -Wno-identities
-Wimplicit-prelude warn when the Prelude is implicitly imported dynamic -Wno-implicit-prelude
-Wincomplete-patterns warn when a pattern match could fail dynamic -Wno-incomplete-patterns
-Wincomplete-uni-patterns warn when a pattern match in a lambda expression or pattern binding could fail dynamic -Wno-incomplete-uni-patterns
-Wmax-pmcheck-iterations= the iteration limit for the pattern match checker dynamic  
-Wincomplete-record-updates warn when a record update could fail dynamic -Wno-incomplete-record-updates
-Wmissing-fields warn when fields of a record are uninitialised dynamic -Wno-missing-fields
-Wmissing-import-lists warn when an import declaration does not explicitly list all thenames brought into scope dynamic -fnowarn-missing-import-lists
-Wmissing-methods warn when class methods are undefined dynamic -Wno-missing-methods
-Wmissing-signatures warn about top-level functions without signatures dynamic -Wno-missing-signatures
-Wmissing-exported-sigs (deprecated) warn about top-level functions without signatures, only if they are exported. takes precedence over -Wmissing-signatures dynamic -Wno-missing-exported-sigs
-Wmissing-exported-signatures warn about top-level functions without signatures, only if they are exported. takes precedence over -Wmissing-signatures dynamic -Wno-missing-exported-signatures
-Wmissing-local-sigs (deprecated) warn about polymorphic local bindings without signatures dynamic -Wno-missing-local-sigs
-Wmissing-local-signatures warn about polymorphic local bindings without signatures dynamic -Wno-missing-local-signatures
-Wmissing-monadfail-instances warn when a failable pattern is used in a do-block that does not have a MonadFail instance. dynamic -Wno-missing-monadfail-instances
-Wsemigroup warn when a Monoid is not Semigroup, and on non-Semigroup definitions of (<>)? dynamic -Wno-semigroup
-Wmissed-specialisations warn when specialisation of an imported, overloaded function fails. dynamic -Wno-missed-specialisations
-Wall-missed-specialisations warn when specialisation of any overloaded function fails. dynamic -Wno-all-missed-specialisations
-Wmonomorphism-restriction warn when the Monomorphism Restriction is applied dynamic -Wno-monomorphism-restriction
-Wname-shadowing warn when names are shadowed dynamic -Wno-name-shadowing
-Wnoncanonical-monad-instances warn when Applicative or Monad instances have noncanonical definitions of return, pure, (>>), or (*>). See flag description in Warnings and sanity-checking for more details. dynamic -Wno-noncanonical-monad-instances
-Wnoncanonical-monadfail-instances warn when Monad or MonadFail instances have noncanonical definitions of fail.See flag description in Warnings and sanity-checking for more details. dynamic -Wno-noncanonical-monadfail-instanc es
-Wnoncanonical-monoid-instances warn when Semigroup or Monoid instances have noncanonical definitions of (<>) or mappend. See flag description in Warnings and sanity-checking for more details. dynamic -Wno-noncanonical-monoid-instances
-Worphans warn when the module contains orphan instance declarations or rewrite rules dynamic -Wno-orphans
-Woverlapping-patterns warn about overlapping patterns dynamic -Wno-overlapping-patterns
-Wtabs warn if there are tabs in the source file dynamic -Wno-tabs
-Wtype-defaults warn when defaulting happens dynamic -Wno-type-defaults
-Wunrecognised-pragmas warn about uses of pragmas that GHC doesn’t recognise dynamic -Wno-unrecognised-pragmas
-Wunticked-promoted-constructors warn if promoted constructors are not ticked dynamic -Wno-unticked-promoted-constructors `
-Wunused-binds warn about bindings that are unused. Alias for -Wunused-top-binds, -Wunused-local-binds and -Wunused-pattern-binds dynamic -Wno-unused-binds
-Wunused-top-binds warn about top-level bindings that are unused dynamic -Wno-unused-top-binds
-Wunused-local-binds warn about local bindings that are unused dynamic -Wno-unused-local-binds
-Wunused-pattern-binds warn about pattern match bindings that are unused dynamic -Wno-unused-pattern-binds
-Wunused-imports warn about unnecessary imports dynamic -Wno-unused-imports
-Wunused-matches warn about variables in patterns that aren’t used dynamic -Wno-unused-matches
-Wunused-foralls warn about type variables in user-written foralls that are unused dynamic -Wno-unused-foralls
-Wunused-type-variables warn about variables in type family or data family instances that are unused dynamic -Wno-unused-type-variables
-Wunused-do-bind warn about do bindings that appear to throw away values of types other than () dynamic -Wno-unused-do-bind
-Wwrong-do-bind warn about do bindings that appear to throw away monadic values that you should have bound instead dynamic -Wno-wrong-do-bind
-Wunsafe 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. dynamic -Wno-unsafe
-Wsafe 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. dynamic -Wno-safe
-Wtrustworthy-safe 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. dynamic -Wno-safe
-Wwarnings-deprecations warn about uses of functions & types that have warnings or deprecated pragmas dynamic -Wno-warnings-deprecations
-Wamp (deprecated) warn on definitions conflicting with the Applicative-Monad Proposal (AMP) dynamic -Wno-amp
-Wredundant-constraints Have the compiler warn about redundant constraints in typesignatures. dynamic -Wno-redundant-constraints
-Wdeferred-type-errors Report warnings when deferred type errors are enabled. This option is enabled by default. See -fdefer-type-errors. dynamic -Wno-deferred-type-errors
-Wtyped-holes Report warnings when typed hole errors are deferred until runtime. See -fdefer-typed-holes. dynamic -Wno-typed-holes
-Wdeferred-out-of-scope-variables Report warnings when variable out-of-scope errors are deferred until runtime. See -fdefer-out-of-scope-variables. dynamic -Wno-deferred-out-of-scope-variable s
-Wpartial-type-signatures 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. dynamic -Wno-partial-type-signatures
-Wderiving-typeable 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. dynamic -Wno-deriving-typeable

7.6.14. Optimisation levels

These options are described in more detail in Optimisation (code improvement).

See Individual optimisations for a list of optimisations enabled on level 1 and level 2.

Flag Description Static/Dynamic Reverse
-O0 Disable optimisations (default) dynamic -O
-O, -O1 Enable level 1 optimisations dynamic -O0
-O2 Enable level 2 optimisations dynamic -O0
-Odph Enable level 2 optimisations, set -fmax-simplifier-iterations=20 and -fsimplifier-phases=3. dynamic  

7.6.15. Individual optimisations

These options are described in more detail in -f*: platform-independent flags. If a flag is implied by -O then it is also implied by -O2 (unless flag description explicitly says otherwise). If a flag is implied by -O0 only then the flag is not implied by -O and -O2.

Flag Description Static/Dynamic Reverse
-fcall-arity Enable call-arity optimisation. Implied by -O. dynamic -fno-call-arity
-fcase-merge Enable case-merging. Implied by -O. dynamic -fno-case-merge
-fcmm-elim-common-blocks Enable Cmm common block elimination. Implied by -O. dynamic -fno-cmm-elim-common-blocks
-fcmm-sink Enable Cmm sinking. Implied by -O. dynamic -fno-cmm-sink
-fcpr-anal Turn on CPR analysis in the demand analyser. Implied by -O. dynamic -fno-cpr-anal
-fcse Enable common sub-expression elimination. Implied by -O. dynamic -fno-cse
-fdicts-cheap Make dictionary-valued expressions seem cheap to the optimiser. dynamic -fno-dicts-cheap
-fdicts-strict Make dictionaries strict dynamic -fno-dicts-strict
-fdmd-tx-dict-sel Use a special demand transformer for dictionary selectors. Always enabled by default. dynamic -fno-dmd-tx-dict-sel
-fdo-eta-reduction Enable eta-reduction. Implied by -O. dynamic -fno-do-eta-reduction
-fdo-lambda-eta-expansion Enable lambda eta-expansion. Always enabled by default. dynamic -fno-do-lambda-eta-expansion
-feager-blackholing Turn on eager blackholing dynamic  
-fenable-rewrite-rules Switch on all rewrite rules (including rules generated by automatic specialisation of overloaded functions). Implied by -O. dynamic -fno-enable-rewrite-rules
-fexcess-precision Enable excess intermediate precision dynamic -fno-excess-precision
-fexpose-all-unfoldings Expose all unfoldings, even for very large or recursive functions. dynamic -fno-expose-all-unfoldings
-ffloat-in Turn on the float-in transformation. Implied by -O. dynamic -fno-float-in
-ffull-laziness Turn on full laziness (floating bindings outwards). Implied by -O. dynamic -fno-full-laziness
-ffun-to-thunk Allow worker-wrapper to convert a function closure into a thunk if the function does not use any of its arguments. Off by default. dynamic -fno-fun-to-thunk
-fignore-asserts Ignore assertions in the source. Implied by -O. dynamic -fno-ignore-asserts
-fignore-interface-pragmas Ignore pragmas in interface files. Implied by -O0 only. dynamic -fno-ignore-interface-pragmas
-flate-dmd-anal Run demand analysis again, at the end of the simplification pipeline dynamic -fno-late-dmd-anal
-fliberate-case Turn on the liberate-case transformation. Implied by -O2. dynamic -fno-liberate-case
-fliberate-case-threshold=⟨n⟩ default: 2000. Set the size threshold for the liberate-case transformation to ⟨n⟩ dynamic -fno-liberate-case-threshold
-floopification Turn saturated self-recursive tail-calls into local jumps in the generated assembly. Implied by -O. dynamic -fno-loopification
-fmax-inline-alloc-size=⟨n⟩ 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). dynamic  
-fmax-inline-memcpy-insns=⟨n⟩ default: 32. Inline memcpy calls if they would generate no more than ⟨n⟩ pseudo instructions. dynamic  
-fmax-inline-memset-insns=⟨n⟩ default: 32. Inline memset calls if they would generate no more than ⟨n⟩ pseudo instructions dynamic  
-fmax-relevant-binds=⟨n⟩ default: 6. Set the maximum number of bindings to display in type error messages. dynamic -fno-max-relevant-bindings
-fmax-simplifier-iterations=⟨n⟩ default: 4. Set the max iterations for the simplifier. dynamic  
-fmax-worker-args=⟨n⟩ default: 10. If a worker has that many arguments, none will be unpacked anymore. dynamic  
-fno-opt-coercion Turn off the coercion optimiser static  
-fno-pre-inlining Turn off pre-inlining dynamic  
-fno-state-hack 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. static  
-fomit-interface-pragmas Don’t generate interface pragmas. Implied by -O0 only. dynamic -fno-omit-interface-pragmas
-fomit-yields Omit heap checks when no allocation is being performed. dynamic -fno-omit-yields
-foptimal-applicative-do Use a slower but better algorithm for ApplicativeDo dynamic -fno-optimal-applicative-do
-fpedantic-bottoms 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. dynamic -fno-pedantic-bottoms
-fregs-graph Use the graph colouring register allocator for register allocation in the native code generator. Implied by -O2. dynamic -fno-regs-graph
-fregs-iterative Use the iterative coalescing graph colouring register allocator in the native code generator. dynamic -fno-regs-iterative
-fsimplifier-phases=⟨n⟩ default: 2. Set the number of phases for the simplifier. Ignored with -O0. dynamic  
-fsimpl-tick-factor=⟨n⟩ default: 100. Set the percentage factor for simplifier ticks. dynamic  
-fspec-constr Turn on the SpecConstr transformation. Implied by -O2. dynamic -fno-spec-constr
-fspec-constr-count=⟨n⟩ default: 3.* Set to ⟨n⟩ the maximum number of specialisations that will be created for any one function by the SpecConstr transformation. dynamic -fno-spec-constr-count
-fspec-constr-threshold=⟨n⟩ default: 2000. Set the size threshold for the SpecConstr transformation to ⟨n⟩. dynamic -fno-spec-constr-threshold
-fspecialise Turn on specialisation of overloaded functions. Implied by -O. dynamic -fno-specialise
-fcross-module-specialise Turn on specialisation of overloaded functions imported from other modules. dynamic -fno-cross-module-specialise
-fstatic-argument-transformation Turn on the static argument transformation. dynamic -fno-static-argument-transformation
-fstrictness Turn on strictness analysis. Implied by -O. Implies -fworker-wrapper dynamic -fno-strictness
-fstrictness-before=⟨n⟩ Run an additional strictness analysis before simplifier phase ⟨n⟩ dynamic  
-funbox-small-strict-fields Flatten strict constructor fields with a pointer-sized representation. Implied by -O. dynamic -fno-unbox-small-strict-fields
-funbox-strict-fields Flatten strict constructor fields dynamic -fno-unbox-strict-fields
-funfolding-creation-threshold=⟨n⟩ default: 750. Tweak unfolding settings. dynamic  
-funfolding-dict-discount=⟨n⟩ default: 30. Tweak unfolding settings. dynamic  
-funfolding-fun-discount=⟨n⟩ default: 60. Tweak unfolding settings. dynamic  
-funfolding-keeness-factor=⟨n⟩ default: 1.5. Tweak unfolding settings. dynamic  
-funfolding-use-threshold=⟨n⟩ default: 60. Tweak unfolding settings. dynamic  
-fvectorisation-avoidance Enable vectorisation avoidance. Always enabled by default. dynamic -fno-vectorisation-avoidance
-fvectorise Enable vectorisation of nested data parallelism dynamic -fno-vectorise
-fworker-wrapper 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. dynamic -fno-worker-wrapper

7.6.16. Profiling options

More details in Profiling

Flag Description Static/Dynamic Reverse
-prof Turn on profiling dynamic  
-fprof-auto Auto-add SCCs to all bindings not marked INLINE dynamic -fno-prof-auto
-fprof-auto-top Auto-add SCCs to all top-level bindings not marked INLINE dynamic -fno-prof-auto
-fprof-auto-exported Auto-add SCCs to all exported bindings not marked INLINE dynamic -fno-prof-auto
-fprof-cafs Auto-add SCCs to all CAFs dynamic -fno-prof-cafs
-fno-prof-count-entries Do not collect entry counts dynamic -fprof-count-entries
-ticky Turn on ticky-ticky profiling dynamic  

7.6.17. Program coverage options

More details in Observing Code Coverage

Flag Description Static/Dynamic Reverse
-fhpc Turn on Haskell program coverage instrumentation dynamic  
-hpcdir dir Directory to deposit .mix files during compilation (default is .hpc) dynamic  

7.6.18. C pre-processor options

More details in Options affecting the C pre-processor

Flag Description Static/Dynamic Reverse
-cpp Run the C pre-processor on Haskell source files dynamic  
-D⟨symbol⟩[=⟨value⟩] Define a symbol in the C pre-processor dynamic -U⟨symbol⟩
-U⟨symbol⟩ Undefine a symbol in the C pre-processor dynamic  
-I⟨dir⟩ Add ⟨dir⟩ to the directory search list for #include files dynamic  

7.6.19. Code generation options

More details in Options affecting code generation

Flag Description Static/Dynamic Reverse
-fasm Use the native code generator dynamic -fllvm
-fllvm Compile using the LLVM code generator dynamic -fasm
-fno-code Omit code generation dynamic  
-fwrite-interface Always write interface files dynamic  
-fbyte-code Generate byte-code dynamic  
-fobject-code Generate object code dynamic  
-g⟨n⟩ 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. dynamic  
-dynamic Build dynamically-linked object files and executables dynamic  
-dynamic-too Build dynamic object files as well as static object files during compilation dynamic  

7.6.20. Linking options

More details in Options affecting linking

Flag Description Static/Dynamic Reverse
-shared Generate a shared library (as opposed to an executable) dynamic  
-staticlib 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. dynamic  
-fPIC Generate position-independent code (where available) dynamic  
-dynload Selects one of a number of modes for finding shared libraries at runtime. dynamic  
-framework⟨name⟩ On Darwin/OS X/iOS only, link in the framework ⟨name⟩. This option corresponds to the -framework option for Apple’s Linker. dynamic  
-framework-path⟨name⟩ 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. dynamic  
-l⟨lib⟩ Link in library ⟨lib⟩ dynamic  
-L⟨dir⟩ Add ⟨dir⟩ to the list of directories searched for libraries dynamic  
-main-is Set main module and function dynamic  
--mk-dll DLL-creation mode (Windows only) dynamic  
-no-hs-main Don’t assume this program contains main dynamic  
-rtsopts,-rtsopts={none,some,all} 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. dynamic  
-with-rtsopts=opts Set the default RTS options to ⟨opts⟩. dynamic  
-no-rtsopts-suggestions Don’t print RTS suggestions about linking with -rtsopts. dynamic  
-no-link Omit linking dynamic  
-split-objs Split objects (for libraries) dynamic  
-split-sections Split sections for link-time dead-code stripping dynamic  
-static Use static Haskell libraries dynamic  
-threaded Use the threaded runtime dynamic  
-debug Use the debugging runtime dynamic  
-ticky For linking, this simply implies -debug; see Using “ticky-ticky” profiling (for implementors). dynamic  
-eventlog Enable runtime event tracing dynamic  
-fno-gen-manifest Do not generate a manifest file (Windows only) dynamic  
-fno-embed-manifest Do not embed the manifest in the executable (Windows only) dynamic  
-fno-shared-implib Don’t generate an import library for a DLL (Windows only) dynamic  
-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) dynamic  
-rdynamic 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. dynamic  

7.6.21. Plugin options

More details in Compiler Plugins

Flag Description Static/Dynamic Reverse
-fplugin=⟨module⟩ Load a plugin exported by a given module dynamic  
-fplugin-opt=⟨module:args⟩ Give arguments to a plugin module; module must be specified with -fplugin dynamic  

7.6.22. Replacing phases

More details in Replacing the program for one or more phases

Flag Description Static/Dynamic Reverse
-pgmL⟨cmd⟩ Use ⟨cmd⟩ as the literate pre-processor dynamic  
-pgmP⟨cmd⟩ Use ⟨cmd⟩ as the C pre-processor (with -cpp only) dynamic  
-pgmc⟨cmd⟩ Use ⟨cmd⟩ as the C compiler dynamic  
-pgmlo⟨cmd⟩ Use ⟨cmd⟩ as the LLVM optimiser dynamic  
-pgmlc⟨cmd⟩ Use ⟨cmd⟩ as the LLVM compiler dynamic  
-pgms⟨cmd⟩ Use ⟨cmd⟩ as the splitter dynamic  
-pgma⟨cmd⟩ Use ⟨cmd⟩ as the assembler dynamic  
-pgml⟨cmd⟩ Use ⟨cmd⟩ as the linker dynamic  
-pgmdll⟨cmd⟩ Use ⟨cmd⟩ as the DLL generator dynamic  
-pgmF⟨cmd⟩ Use ⟨cmd⟩ as the pre-processor (with -F only) dynamic  
-pgmwindres⟨cmd⟩ Use ⟨cmd⟩ as the program for embedding manifests on Windows. dynamic  
-pgmlibtool⟨cmd⟩ Use ⟨cmd⟩ as the command for libtool (with -staticlib only). dynamic  

7.6.23. Forcing options to particular phases

More details in Forcing options to a particular phase

Flag Description Static/Dynamic Reverse
-optL⟨option⟩ pass ⟨option⟩ to the literate pre-processor dynamic  
-optP⟨option⟩ pass ⟨option⟩ to cpp (with -cpp only) dynamic  
-optF⟨option⟩ pass ⟨option⟩ to the custom pre-processor dynamic  
-optc⟨option⟩ pass ⟨option⟩ to the C compiler dynamic  
-optlo⟨option⟩ pass ⟨option⟩ to the LLVM optimiser dynamic  
-optlc⟨option⟩ pass ⟨option⟩ to the LLVM compiler dynamic  
-opta⟨option⟩ pass ⟨option⟩ to the assembler dynamic  
-optl⟨option⟩ pass ⟨option⟩ to the linker dynamic  
-optdll⟨option⟩ pass ⟨option⟩ to the DLL generator dynamic  
-optwindres⟨option⟩ pass ⟨option⟩ to windres. dynamic  

7.6.24. Platform-specific options

More details in Platform-specific Flags

Flag Description Static/Dynamic Reverse
-msse2 (x86 only) Use SSE2 for floating-point operations dynamic  
-msse4.2 (x86 only) Use SSE4.2 for floating-point operations dynamic  

7.6.25. Compiler debugging options

More details in Debugging the compiler

Flag Description Static/Dynamic Reverse
-dcore-lint Turn on internal sanity checking dynamic  
-ddump-to-file Dump to files instead of stdout dynamic  
-ddump-asm Dump assembly dynamic  
-ddump-bcos Dump interpreter byte code dynamic  
-ddump-cmm Dump C– output dynamic  
-ddump-core-stats Print a one-line summary of the size of the Core program at the end of the optimisation pipeline dynamic  
-ddump-cse Dump CSE output dynamic  
-ddump-deriv Dump deriving output dynamic  
-ddump-ds Dump desugarer output dynamic  
-ddump-foreign Dump foreign export stubs dynamic  
-ddump-hpc Dump after instrumentation for program coverage dynamic  
-ddump-inlinings Dump inlining info dynamic  
-ddump-llvm Dump LLVM intermediate code. Implies -fllvm. dynamic  
-ddump-occur-anal Dump occurrence analysis output dynamic  
-ddump-opt-cmm Dump the results of C– to C– optimising passes dynamic  
-ddump-parsed Dump parse tree dynamic  
-ddump-prep Dump prepared core dynamic  
-ddump-rn Dump renamer output dynamic  
-ddump-rule-firings Dump rule firing info dynamic  
-ddump-rule-rewrites Dump detailed rule firing info dynamic  
-ddump-rules Dump rules dynamic  
-ddump-vect Dump vectoriser input and output dynamic  
-ddump-simpl Dump final simplifier output dynamic  
-ddump-simpl-iterations Dump output from each simplifier iteration dynamic  
-ddump-spec Dump specialiser output dynamic  
-ddump-splices Dump TH spliced expressions, and what they evaluate to dynamic  
-ddump-stg Dump final STG dynamic  
-ddump-stranal Dump strictness analyser output dynamic  
-ddump-str-signatures Dump strictness signatures dynamic  
-ddump-tc Dump typechecker output dynamic  
-dth-dec-file Show evaluated TH declarations in a .th.hs file dynamic  
-ddump-types Dump type signatures dynamic  
-ddump-worker-wrapper Dump worker-wrapper output dynamic  
-ddump-if-trace Trace interface files dynamic  
-ddump-tc-trace Trace typechecker dynamic  
-ddump-vt-trace Trace vectoriser dynamic  
-ddump-rn-trace Trace renamer dynamic  
-ddump-rn-stats Renamer stats dynamic  
-ddump-simpl-stats Dump simplifier stats dynamic  
-dno-debug-output Suppress unsolicited debugging output static  
-dppr-debug Turn on debug printing (more verbose) static  
-dppr-user-length Set the depth for printing expressions in error msgs dynamic  
-dppr-cols⟨N⟩ Set the width of debugging output. For example -dppr-cols200 dynamic  
-dppr-case-as-let Print single alternative case expressions as strict lets. dynamic  
-dsuppress-all In core dumps, suppress everything (except for uniques) that is suppressible. dynamic  
-dsuppress-uniques Suppress the printing of uniques in debug output (easier to use diff) dynamic  
-dsuppress-idinfo Suppress extended information about identifiers where they are bound dynamic  
-dsuppress-unfoldings Suppress the printing of the stable unfolding of a variable at its binding site dynamic  
-dsuppress-module-prefixes Suppress the printing of module qualification prefixes dynamic  
-dsuppress-type-signatures Suppress type signatures dynamic  
-dsuppress-type-applications Suppress type applications dynamic  
-dsuppress-coercions Suppress the printing of coercions in Core dumps to make them shorter dynamic  
-dsource-stats Dump haskell source stats dynamic  
-dcmm-lint C– pass sanity checking dynamic  
-dstg-lint STG pass sanity checking dynamic  
-dstg-stats Dump STG stats dynamic  
-dverbose-core2core Show output from each core-to-core pass dynamic  
-dverbose-stg2stg Show output from each STG-to-STG pass dynamic  
-dshow-passes Print out each pass name as it happens dynamic  
-dfaststring-stats Show statistics for fast string usage when finished dynamic  
-frule-check Report sites with rules that could have fired but didn’t. Takes a string argument. dynamic  

7.6.26. Miscellaneous compiler options

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