summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2012-08-14 17:31:48 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2012-08-14 17:31:48 +0100
commitca9986a3f6d4d5e3c62dffe1b6d1c119ad1f9267 (patch)
tree9bfa9b69f3dcaea9bc13edff9b4dc178dbc90c86 /docs
parent3fabf48e0c5be2d7c2f6ea028115fdb9b4045d97 (diff)
downloadhaskell-ca9986a3f6d4d5e3c62dffe1b6d1c119ad1f9267.tar.gz
Improve documentation of the way that defaulting to IO happens in GHCi
Thanks to John Hughes for the suggestion.
Diffstat (limited to 'docs')
-rw-r--r--docs/users_guide/ghci.xml14
1 files changed, 12 insertions, 2 deletions
diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml
index 5726a41baf..c7d3cc5c57 100644
--- a/docs/users_guide/ghci.xml
+++ b/docs/users_guide/ghci.xml
@@ -358,10 +358,10 @@ Prelude> 5+5
</screen>
</para>
-<sect2><title>I/O actions at the prompt</title>
+<sect2 id="actions-at-prompt"><title>I/O actions at the prompt</title>
<para>GHCi does more than simple expression evaluation at the prompt.
-If you type something of type <literal>IO a</literal> for some
+If you enter an expression of type <literal>IO a</literal> for some
<literal>a</literal>, then GHCi <emphasis>executes</emphasis> it
as an IO-computation.
<screen>
@@ -370,6 +370,12 @@ Prelude> "hello"
Prelude> putStrLn "hello"
hello
</screen>
+This works even if the type of the expression is more general,
+provided it can be <emphasis>instantiated</emphasis> to <literal>IO a</literal>. For example
+<screen>
+Prelude> return True
+True
+</screen>
Furthermore, GHCi will print the result of the I/O action if (and only
if):
<itemizedlist>
@@ -1089,7 +1095,11 @@ def = toEnum 0
<literal>Integer</literal> then ghci gives an error when running a
printf.
</para>
+ <para>See also <xref linkend="actions-at-prompt"/> for how the monad of a computational
+ expression defaults to <literal>IO</literal> if possible.
+ </para>
</sect2>
+
<sect2 id="ghci-interactive-print">
<title>Using a custom interactive printing function</title>
<para>[<emphasis role="bold">New in version 7.6.1</emphasis>]