- Overview of options
- Allow multiline commands (
- Show types (
- Show statistics (
- Collect source information (
:set command can be used to change various behaviors of GHCi from within a running REPL. Options set with the
:set command can be undone with the
:unset command. If you want them on each time you open a new GHCi session, options set with the
:seti command can also be enabled in your GHCi configuration file.
You can view a list of all the options that are currently
:set, whether it’s because they are the default options or because they are turned on in, say, your GHCi configuration, by typing
:seti with no arguments at the prompt.
λ> :set options currently set: +t base language is: Haskell2010 with the following modifiers: -XNoDatatypeContexts -XExplicitForAll -XNondecreasingIndentation -XPatternSignatures -XScopedTypeVariables -XTypeApplications GHCi-specific dynamic flag settings: other dynamic, non-language, flag settings: -fexternal-dynamic-refs -fignore-optim-changes -fignore-hpc-changes -fimplicit-import-qualified warning settings:
Some of these are turned on in the author’s GHCi configuration, and some are GHCi’s defaults. We’ll discuss the difference between
:seti more below, but doing the above with
:seti instead of
:set may return a different set of options and modifiers due to the difference between the two commands.
Overview of options
Options starting with
+ are specific to GHCi. This is the complete list:These options are also listed in the GHCi options section of the GHC manual.
+m– Allow multiline commands.
+r– Discard evaluation of top-level expressions after each evaluation. We don’t have much to say about the
+roption at this time because, so far as we can tell, it does not work on interpreted code, hence its utility seems limited to us and this is, after all, an opinionated guide to using GHCi in the ways that we use it.
+s– Display statistics about time and memory usage after each evaluation.
+t– Print an expression’s type after each evaluation.
+c– Collect source information needed to support the
Options starting with
- are GHC command-line options. The list of these is long, but here are a few examples:
-v– Set higher debug output verbosity
-Wall– Enable all compiler warnings
-XOverloadedStrings– Enable the
Many of these will be covered in their own articles, because they are not specific to GHCi.