• Overview of options
  • The :seti difference
  • Allow multiline commands (+m)
  • Show types (+t)
  • Show statistics (+s)
  • Collect source information (+c)

The :set commandGHC documentation: :set, :unset, :seti 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 :set or :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 :set or :seti with no arguments at the prompt.

λ> :set
options currently set: +t
base language is: Haskell2010
with the following modifiers:
GHCi-specific dynamic flag settings:
other dynamic, non-language, flag settings:
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 :set and :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 evaluationWe don’t have much to say about the +r option 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. of top-level expressions after each evaluation.
  • +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 :all-types, :loc-at, :type-at, and :uses commands.

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 OverloadedStrings extension

Many of these will be covered in their own articles, because they are not specific to GHCi.

Sign up for access to the full page, plus the complete archive and all the latest content.