summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2007-11-07 11:17:57 +0000
committerSimon Marlow <simonmar@microsoft.com>2007-11-07 11:17:57 +0000
commitda4dda13a3faf2ecc2138d16b7faa79cff264037 (patch)
tree5c13e7e49ea34e888dbad8943f802de20fad192c /docs
parent806ab6331b967d6176b8790a0b1b551ec0e8e2b6 (diff)
downloadhaskell-da4dda13a3faf2ecc2138d16b7faa79cff264037.tar.gz
FIX #1765, #1766
- :def! now overwrites a previous command with the same name - :def on its own lists the defined macros - ":undef f g" undefines both f and g
Diffstat (limited to 'docs')
-rw-r--r--docs/users_guide/ghci.xml41
1 files changed, 24 insertions, 17 deletions
diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml
index 28e9972b24..b092953b36 100644
--- a/docs/users_guide/ghci.xml
+++ b/docs/users_guide/ghci.xml
@@ -1817,26 +1817,27 @@ $ ghci -lm
<varlistentry>
<term>
- <literal>:def</literal> <replaceable>name</replaceable> <replaceable>expr</replaceable>
+ <literal>:def<optional>!</optional> <optional><replaceable>name</replaceable> <replaceable>expr</replaceable></optional></literal>
<indexterm><primary><literal>:def</literal></primary></indexterm>
</term>
<listitem>
- <para>The command <literal>:def</literal>
- <replaceable>name</replaceable>
- <replaceable>expr</replaceable> defines a new GHCi command
- <literal>:<replaceable>name</replaceable></literal>,
- implemented by the Haskell expression
- <replaceable>expr</replaceable>, which must have type
- <literal>String -> IO String</literal>. When
- <literal>:<replaceable>name</replaceable>
- <replaceable>args</replaceable></literal> is typed at the
- prompt, GHCi will run the expression
- <literal>(<replaceable>name</replaceable>
- <replaceable>args</replaceable>)</literal>, take the
- resulting <literal>String</literal>, and feed it back into
- GHCi as a new sequence of commands. Separate commands in
- the result must be separated by
- &lsquo;<literal>\n</literal>&rsquo;.</para>
+ <para><literal>:def</literal> is used to define new
+ commands, or macros, in GHCi. The command
+ <literal>:def</literal> <replaceable>name</replaceable>
+ <replaceable>expr</replaceable> defines a new GHCi command
+ <literal>:<replaceable>name</replaceable></literal>,
+ implemented by the Haskell expression
+ <replaceable>expr</replaceable>, which must have type
+ <literal>String -> IO String</literal>. When
+ <literal>:<replaceable>name</replaceable>
+ <replaceable>args</replaceable></literal> is typed at the
+ prompt, GHCi will run the expression
+ <literal>(<replaceable>name</replaceable>
+ <replaceable>args</replaceable>)</literal>, take the
+ resulting <literal>String</literal>, and feed it back into
+ GHCi as a new sequence of commands. Separate commands in
+ the result must be separated by
+ &lsquo;<literal>\n</literal>&rsquo;.</para>
<para>That's all a little confusing, so here's a few
examples. To start with, here's a new GHCi command which
@@ -1880,6 +1881,12 @@ Prelude> :. cmds.ghci
<literal>:.</literal>, by analogy with the
&lsquo;<literal>.</literal>&rsquo; Unix shell command that
does the same thing.</para>
+
+ <para>Typing <literal>:def</literal> on its own lists the
+ currently-defined macros. Attempting to redefine an
+ existing command name results in an error unless the
+ <literal>:def!</literal> form is used, in which case the old
+ command with that name is silently overwritten.</para>
</listitem>
</varlistentry>