List of GHCi commands

Here is an exhaustive, annotated list of GHCi commands, somewhat divided by task. Some important ones are covered in more detail in their own lessons.


First, we start with the absolute basics.

  • : – The colon by itself repeats the previous command.
  • :? or :help – Gives you some help.
  • :! <cmd> – Allows you to use shell commands, such as pwd in ghci. This is also useful to people building tools on top of GHCi.
  • :cd – Changes the directory that ghci has access to.
  • :load <file> – Loads the specified file into the GHCi session. Without an argument, it unloads whatever had previously been loaded.
  • :main <args> – Runs a main with some arguments.
  • :quit – Quit GHCi.
  • :reload – Does not take an argument. Reloads the current module, file, or project.
  • :set – This is used for many things; please see the article.
  • :seti – Like :set, but only affects commands typed at the GHCi prompt, not those loaded from a file.
  • :run <name> <args> – Similar to :main.
  • :unset – Undoes :set.

Information about types and functions

Next you should become familiar with these commands for querying information about Haskell types and functions.

  • :doc <arg> – (new, unstable) Show the documentation for a Haskell type, etc., right in the REPL.
  • :info – Queries information about a type, typeclass, value, function, or operator.
  • :kind – Queries the kind of a type.
  • :type – Queries the type of a value or function.
  • :type-at

Scope and availability

This set of commands is used for finding information about what’s in scope or changing what is in scope.

  • :add – Adds a module to the current target set and reloads.
  • :all-types – Lists all types for expressions and local bindings that are currently loaded.
  • :browse – Gives a list of the contents of a module (the module need not be imported).
  • :issafe <module> – Tells you the Safe Haskell information for a module (the current one if none is specified).
  • :module – Imports or de-imports modules. Can be used to expose an entire module, rather than only its exports.
  • :show – Followed by modules, it lists the modules that are currently in scope; followed by imports, it lists the imports that are in scope.

Debugging and evaluation

And here is a list of commands that are part of GHCi’s built-in debugging tools or useful for examining the evaluation of Haskell expressions.

  • :abandon – Abandons the current evaulation when stopped at a breakpoint.
  • :back <n> – Travel back <n> steps in the history. <n> is 1 when unspecified.
  • :break – Used to set a breakpoint.
  • :continue – Used to continue evaluation after a breakpoint.
  • :delete – Takes an argument: a number or *. Deletes the specified number of breakpoints. If given *, deletes all breakpoints.
  • :force <id> – Forces the printing of the identifier passed to it as an argument, forcing all the thunks along the way.
  • :forward <n> – Moves forward <n> steps in the history. <n> is 1 when unspecified.
  • :history <n> – Displays the history of the evaluation. If given a numeric argument, it displays that number of steps; otherwise, the default is 20.
  • :list <id> – Lists the source code around the definition of the identifier or the current breakpoint.
  • :print <id> – Prints a value without forcing its evaluation.
  • :sprint – Prints what has been evaluated so far while showing thunks with an underscore. Helpful for understanding laziness.
  • :step – Enables single-stepping through program evaluation. There is also :steplocal and :stepmodule.
  • :trace <expr> – Traces evaluation of the expression and logs it for later inspection.

Advanced, less common

Most of these are not commonly used unless you are building something on top of GHCi or working on editor or IDE integration.

  • :cmd
  • :complete
  • :ctags – Important for shaving certain Vi-style yaks.
  • :def – Takes arguments. Allows you to define custom GHCi commands and macros.
  • :edit <file> – Opens an editor to permit editing of a file, either the one passed to it as an argument or the currently loaded one.
  • :etags – This one is for the Emacs-flavored yaks.
  • :loc-at – Used for IDE and editor integration.
  • :script <file> – When given a filename as an argument, it executes the lines of code in that file as a series of GHCi commands.
  • :undef – Undoes whatever you did with :def.
  • :uses

Join Type Classes for courses and projects to get you started and make you an expert in FP with Haskell.