:set command sets two types of
options: GHCi options, which begin with
+’, and “command-line”
options, which begin with ‘-’.
NOTE: at the moment, the
doesn't support any kind of quoting in its arguments: quotes will
not be removed and cannot be used to group words together. For
:set -DFOO='BAR BAZ' will not do what
GHCi options may be set using
The available GHCi options are:
Enable parsing of multiline commands. A multiline command is prompted for when the current input line contains open layout contexts (see Section 2.4.3, “Multiline input”).
Normally, any evaluation of top-level expressions
(otherwise known as CAFs or Constant Applicative Forms) in
loaded modules is retained between evaluations. Turning
+r causes all evaluation of
top-level expressions to be discarded after each
evaluation (they are still retained
during a single evaluation).
This option may help if the evaluated top-level expressions are consuming large amounts of space, or if you need repeatable performance measurements.
Display some stats after evaluating each expression, including the elapsed time and number of bytes allocated. NOTE: the allocation figure is only accurate to the size of the storage manager's allocation area, because it is calculated at every GC. Hence, you might see values of zero if no GC has occurred.
Display the type of each variable bound after a
statement is entered at the prompt. If the statement is a
single expression, then the only variable binding will be
for the variable
Normal GHC command-line options may also be set using
:set. For example, to turn on
-fwarn-missing-signatures, you would say:
Prelude> :set -fwarn-missing-signatures
Any GHC command-line option that is designated as
dynamic (see the table in Section 4.19, “Flag reference”), may be set using
:set. To unset an option, you can set the
Prelude> :set -fno-warn-incomplete-patterns -XNoMultiParamTypeClasses
Section 4.19, “Flag reference” lists the reverse for each option where applicable.
Certain static options (
-l in particular) will also work, but some may
not take effect until the next reload.
GHCi actually maintains two sets of options:
The loading options apply when loading modules
The interactive options apply when evaluating expressions and commands typed at the GHCi prompt.
:set command modifies both, but there is
:seti command (for "set
interactive") that affects only the interactive options set.
It is often useful to change the interactive options, without having that option apply to loaded modules too. For example
It would be undesirable if
-XMonoLocalBinds were to
apply to loaded modules too: that might cause a compilation error, but
more commonly it will cause extra recompilation, because GHC will think
that it needs to recompile the module because the flags have changed.
If you are setting language options in your
.ghci file, it is good practice
:seti rather than
unless you really do want them to apply to all modules you
load in GHCi.
The two sets of options can be inspected using the
respectively, with no arguments. For example, in a clean GHCi
session we might see something like this:
Prelude> :seti base language is: Haskell2010 with the following modifiers: -XNoMonomorphismRestriction -XNoDatatypeContexts -XNondecreasingIndentation -XExtendedDefaultRules GHCi-specific dynamic flag settings: other dynamic, non-language, flag settings: -fimplicit-import-qualified warning settings:
The two sets of options are initialised as follows. First, both sets of options
are initialised as described in Section 2.9, “The
Then the interactive options are modified as follows:
is enabled, in order to apply special defaulting rules to
expressions typed at the prompt (see Section 2.4.8, “Type defaulting in GHCi”).
The Monomorphism Restriction is disabled (see Section 126.96.36.199, “Switching off the dreaded Monomorphism Restriction”).