You can say :set -fno-print-bind-result in GHCi to disable this behaviour.
Addresses #887
| Opt_SplitObjs
| Opt_StgStats
| Opt_HideAllPackages
+ | Opt_PrintBindResult
-- keeping stuff
| Opt_KeepHiDiffs
Opt_IgnoreInterfacePragmas,
Opt_OmitInterfacePragmas
+ -- on by default:
+ Opt_PrintBindResult
] ++ standardWarnings,
log_action = \severity srcSpan style msg ->
( "unbox-strict-fields", Opt_UnboxStrictFields ),
( "dicts-cheap", Opt_DictsCheap ),
( "excess-precision", Opt_ExcessPrecision ),
- ( "asm-mangling", Opt_DoAsmMangling )
+ ( "asm-mangling", Opt_DoAsmMangling ),
+ ( "print-bind-result", Opt_PrintBindResult )
]
glasgowExtsFlags = [
| [L _ v] <- collectLStmtBinders stmt -- One binder, for a bind stmt
= do { let print_v = L loc $ ExprStmt (nlHsApp (nlHsVar printName) (nlHsVar v))
(HsVar thenIOName) placeHolderType
+
+ ; print_bind_result <- doptM Opt_PrintBindResult
+ ; let print_plan = do
+ { stuff@([v_id], _) <- tcGhciStmts [stmt, print_v]
+ ; v_ty <- zonkTcType (idType v_id)
+ ; ifM (isUnitTy v_ty || not (isTauTy v_ty)) failM
+ ; return stuff }
+
-- The plans are:
-- [stmt; print v] but not if v::()
-- [stmt]
- ; runPlans [do { stuff@([v_id], _) <- tcGhciStmts [stmt, print_v]
- ; v_ty <- zonkTcType (idType v_id)
- ; ifM (isUnitTy v_ty || not (isTauTy v_ty)) failM
- ; return stuff },
- tcGhciStmts [stmt]
- ]}
+ ; runPlans ((if print_bind_result then [print_plan] else []) ++
+ [tcGhciStmts [stmt]])
+ }
mkPlan stmt
= tcGhciStmts [stmt]
See <xref linkend="ghci-commands" /> for more information.
</para>
</listitem>
+ <listitem>
+ <para>
+ GHCi now invokes <literal>print</literal> by default on the
+ result of IO actions and bindings at the prompt. This is
+ occasionally not what you want, so it can be disabled (at
+ least for bindings) with
+ <literal>:set -fno-print-bind-result</literal>. See <xref
+ linkend="ghci-stmts" />.</para>
+ </listitem>
</itemizedlist>
</sect2>
<entry>dynamic</entry>
<entry>-</entry>
</row>
+ <row>
+ <entry><option>-fno-print-bind-result</option></entry>
+ <entry><link id="ghci-stmts">Turn off printing of binding results in GHCi</link></entry>
+ <entry>dynamic</entry>
+ <entry>-</entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
</screen>
</para></sect2>
- <sect2>
+ <sect2 id="ghci-stmts">
<title>Using <literal>do-</literal>notation at the prompt</title>
<indexterm><primary>do-notation</primary><secondary>in GHCi</secondary></indexterm>
<indexterm><primary>statements</primary><secondary>in GHCi</secondary></indexterm>
<literal>Show</literal></para>
</listitem>
</itemizedlist>
- </para>
+ The automatic printing of binding results can be supressed with
+ <option>:set -fno-print-bind-result</option> (this does not
+ supress printing the result of non-binding statements).
+ <indexterm><primary><option>-fno-print-bind-result</option></primary></indexterm><indexterm><primary><option>-fprint-bind-result</option></primary></indexterm>.
+ You might want to do this to prevent the result of binding
+ statements from being fully evaluated by the act of printing
+ them, for example.</para>
<para>Of course, you can also bind normal non-IO expressions
using the <literal>let</literal>-statement:</para>