Ticket #5461: 0001-Docs-are-updated-according-to-FR-5461.patch

File 0001-Docs-are-updated-according-to-FR-5461.patch, 3.4 KB (added by bravit, 6 years ago)
  • docs/users_guide/flags.xml

    From 5fe4a4be1d1bfa157664697403e5a9dd0b19ba5a Mon Sep 17 00:00:00 2001
    From: Vitaly Bragilevsky <bravit111@gmail.com>
    Date: Fri, 29 Jun 2012 23:58:03 +0400
    Subject: [PATCH] Docs are updated according to FR (#5461)
    
    ---
     docs/users_guide/flags.xml |  7 +++++++
     docs/users_guide/ghci.xml  | 50 ++++++++++++++++++++++++++++++++++++++++++++++
     2 files changed, 57 insertions(+)
    
    diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml
    index 3b4f36d..5344902 100644
    a b  
    535535            <entry>dynamic</entry>
    536536            <entry>-</entry>
    537537          </row>
     538          <row>
     539            <entry><option>-interactive-print</option></entry>
     540            <entry><link linkend="ghci-interactive-print">Setup function for printing
     541                  results of evaluated expressions</link></entry>
     542            <entry>dynamic</entry>
     543            <entry>-</entry>
     544          </row>
    538545
    539546        </tbody>
    540547      </tgroup>
  • docs/users_guide/ghci.xml

    diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml
    index 3d629db..d458ffb 100644
    a b def = toEnum 0 
    10901090    printf.
    10911091   </para>
    10921092    </sect2>
     1093   <sect2 id="ghci-interactive-print">
     1094     <title>Using specific interactive printing function</title>
     1095     <para>[<emphasis role="bold">New in version 7.6.1</emphasis>]
     1096        GHCi by default prints the results of expressions typed at the prompt using
     1097        <literal>System.IO.print</literal> function. It's type signature is
     1098        <literal>Show a => a -> IO ()</literal>, and prior to printing
     1099        the value is converted to <literal>String</literal> via <literal>show</literal>.
     1100        The output is often unreadable, especially when it's quite long.
     1101        This conversion among other consequences encodes any non-ascii characters what
     1102        makes using GHCi with many non-english locales very inconvenient.
     1103     </para>
     1104     <para>
     1105       The command-line parameter <literal>-interactive-print</literal> allows to
     1106       setup any function of type <literal>C a => a -> IO ()</literal> as the function
     1107       for printing the results of expressions. The function should reside in any loaded module
     1108       or any registered package.
     1109     </para>
     1110     <para>
     1111       Suppose we have following special printing module:
     1112       <programlisting>
     1113         module SpecPrinter where
     1114         import System.IO
     1115
     1116         sprint a = putStrLn $ show a ++ "!"
     1117       </programlisting>
     1118       Function <literal>sprint</literal> adds exclamation mark to the end of any printed value.
     1119       Running GHCi with the command:
     1120       <programlisting>
     1121         ghci -interactive-print=SpecPrinter.sprinter SpecPrinter
     1122       </programlisting>
     1123       could bring to this session:
     1124       <programlisting>
     1125         *SpecPrinter> [1,2,3]
     1126         [1,2,3]!
     1127         *SpecPrinter> 42
     1128         42!
     1129       </programlisting>
     1130       Obviously, you can adopt any pretty printing function of the given type
     1131       (<literal>C a => a -> IO ()</literal>) to obtain desired output like trees printed by levels
     1132       or lists of lists printed with one nested list per line.
     1133     </para>
     1134
     1135     <para>
     1136       This command-line parameter is also useful when running GHC in <literal>-e mode</literal>:
     1137       <programlisting>
     1138         % ghc -e "42" -interactive-print=SpecPrinter.sprint SpecPrinter
     1139         [1,2,3]!
     1140       </programlisting>
     1141     </para>
     1142   </sect2>
    10931143  </sect1>
    10941144
    10951145  <sect1 id="ghci-debugger">