Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>After reading your reply to my comment, I think your situation is that you have some data structure, maybe with type <code>[(String,String)]</code>, and you'd like to output it for debugging purposes. Using <code>show</code> would be convienent, but it escapes non-ASCII characters.</p> <p>The problem here isn't with the unicode, you need a function that will properly format your data for display. I don't think <code>show</code> is the right choice, in part because of the problems with escaping some characters. What you need is a type class like <code>Show</code>, but one that displays data for reading instead of escaping characters. That is, you need a pretty-printer, which is a library that provides functions to format data for display. There are several pretty-printers available on Hackage, I'd look at <a href="http://hackage.haskell.org/package/uulib" rel="nofollow noreferrer">uulib</a> or <a href="http://hackage.haskell.org/package/wl-pprint" rel="nofollow noreferrer">wl-pprint</a> to start. I think either would be suitable without too much work.</p> <p>Here's an example with the uulib tools. The <code>Pretty</code> type class is used instead of Show, the library comes with many useful instances.</p> <pre><code>import UU.PPrint -- | Write each item to StdOut logger :: Pretty a =&gt; a -&gt; IO () logger x = putDoc $ pretty x &lt;+&gt; line </code></pre> <p>running this in ghci:</p> <pre><code>Prelude UU.PPrint&gt; logger 'Д' Д Prelude UU.PPrint&gt; logger ('Д', "other text", 54) (Д,other text,54) Prelude UU.PPrint&gt; </code></pre> <p>If you want to output to a file instead of the console, you can use the <code>hPutDoc</code> function to output to a handle. You could also call <code>renderSimple</code> to produce a <code>SimpleDoc</code>, then pattern match on the constructors to process output, but that's probably more trouble. Whatever you do, avoid <code>show</code>:</p> <pre><code>Prelude UU.PPrint&gt; show $ pretty 'Д' "\1044" </code></pre> <p>You could also write your own type class similar to show but formatted as you like it. The <code>Text.Printf</code> module can be helpful if you go this route.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload