07.01.2014 Views

The Glorious Glasgow Haskell Compilation System User's Guide ...

The Glorious Glasgow Haskell Compilation System User's Guide ...

The Glorious Glasgow Haskell Compilation System User's Guide ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>The</strong> <strong>Glorious</strong> <strong>Glasgow</strong> <strong>Haskell</strong><br />

<strong>Compilation</strong> <strong>System</strong> User’s <strong>Guide</strong>,<br />

Version 6.10.4 33 / 224<br />

:set [option...] Sets various options. See Section 2.8 for a list of available options and Section 4.17.10 for a list of GHCispecific<br />

flags. <strong>The</strong> :set command by itself shows which options are currently set. It also lists the current dynamic flag<br />

settings, with GHCi-specific flags listed separately.<br />

:set args arg ...<br />

:set editor cmd<br />

:set prog prog<br />

Sets the list of arguments which are returned when the program calls <strong>System</strong>.getArgs.<br />

Sets the command used by :edit to cmd.<br />

Sets the string to be returned when the program calls <strong>System</strong>.getProgName.<br />

:set prompt prompt Sets the string to be used as the prompt in GHCi. Inside prompt, the sequence %s is replaced by the<br />

names of the modules currently in scope, and %% is replaced by %.<br />

:set stop [num] cmd Set a command to be executed when a breakpoint is hit, or a new item in the history is selected. <strong>The</strong><br />

most common use of :set stop is to display the source code at the current location, e.g. :set stop :list.<br />

If a number is given before the command, then the commands are run when the specified breakpoint (only) is hit. This can<br />

be quite useful: for example, :set stop 1 :continue effectively disables breakpoint 1, by running :continue<br />

whenever it is hit (although GHCi will still emit a message to say the breakpoint was hit). What’s more, with cunning use<br />

of :def and :cmd you can use :set stop to implement conditional breakpoints:<br />

*Main> :def cond \expr -> return (":cmd if (" ++ expr ++ ") then return \"\" else<br />

return \":continue\"")<br />

*Main> :set stop 0 :cond (x < 3)<br />

Ignoring breakpoints for a specified number of iterations is also possible using similar techniques.<br />

:show bindings<br />

:show breaks<br />

Show the bindings made at the prompt and their types.<br />

List the active breakpoints.<br />

:show context List the active evaluations that are stopped at breakpoints.<br />

:show modules Show the list of modules currently loaded.<br />

:show packages<br />

Show the currently active package flags, as well as the list of packages currently loaded.<br />

:show languages Show the currently active language flags.<br />

:show [args|prog|prompt|editor|stop]<br />

Displays the specified setting (see :set).<br />

:sprint Prints a value without forcing its evaluation. :sprint is similar to :print, with the difference that unevaluated<br />

subterms are not bound to new variables, they are simply denoted by ‘_’.<br />

:step [expr] Single-step from the last breakpoint. With an expression argument, begins evaluation of the expression with<br />

a single-step.<br />

:trace [expr] Evaluates the given expression (or from the last breakpoint if no expression is given), and additionally logs<br />

the evaluation steps for later inspection using :history. See Section 2.5.5.<br />

:type expression Infers and prints the type of expression, including explicit forall quantifiers for polymorphic types.<br />

<strong>The</strong> monomorphism restriction is not applied to the expression during type inference.<br />

:undef name<br />

:unset option...<br />

Undefines the user-defined command name (see :def above).<br />

Unsets certain options. See Section 2.8 for a list of available options.<br />

:! command... Executes the shell command command.<br />

←↪<br />

2.8 <strong>The</strong> :set command<br />

<strong>The</strong> :set command sets two types of options: GHCi options, which begin with ‘+’, and “command-line” options, which begin<br />

with ‘-’.<br />

NOTE: at the moment, the :set command doesn’t support any kind of quoting in its arguments: quotes will not be removed<br />

and cannot be used to group words together. For example, :set -DFOO=’BAR BAZ’ will not do what you expect.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!