Commit ca9986a3 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Improve documentation of the way that defaulting to IO happens in GHCi

Thanks to John Hughes for the suggestion.
parent 3fabf48e
......@@ -358,10 +358,10 @@ Prelude> 5+5
<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.
......@@ -370,6 +370,12 @@ Prelude> "hello"
Prelude> putStrLn "hello"
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
Prelude> return True
Furthermore, GHCi will print the result of the I/O action if (and only
......@@ -1088,8 +1094,12 @@ def = toEnum 0
doesn't require extensions to the class system), so if the type defaults to
<literal>Integer</literal> then ghci gives an error when running a
<para>See also <xref linkend="actions-at-prompt"/> for how the monad of a computational
expression defaults to <literal>IO</literal> if possible.
<sect2 id="ghci-interactive-print">
<title>Using a custom interactive printing function</title>
<para>[<emphasis role="bold">New in version 7.6.1</emphasis>]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment