<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">Pretty-printing – Haskell – Aelve Guide</title><id>https://guide.aelve.com/haskell/feed/category/uhierj0c</id><updated>2018-08-14T13:25:22Z</updated><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/feed/category/uhierj0c"/><entry><id>r7fq4cvr</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">pretty-simple</title><updated>2018-08-14T13:25:22Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;pretty-simple&lt;/span&gt;

  
  (&lt;a href=&#34;https://hackage.haskell.org/package/pretty-simple&#34;&gt;Hackage&lt;/a&gt;)
&lt;/h1&gt;&lt;p&gt;&lt;code&gt;pretty-simple&lt;/code&gt; is a pretty printer for Haskell data types that have a Show instance.&lt;/p&gt;
&lt;h2&gt;Pros&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;can turn deriving(Show) into something readable automatically&lt;/li&gt;&lt;/p&gt;&lt;p&gt;&lt;li&gt;includes a drop-in replacement for Debug.Trace&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;&lt;h2&gt;Cons&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;more limited than prettyprinter if you intend to write your own printers&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/pretty-printing-uhierj0c#item-r7fq4cvr"/></entry><entry><id>g3bsxslp</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">prettyprinter</title><updated>2017-09-27T20:43:00Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;a href=&#34;https://github.com/quchen/prettyprinter&#34; class=&#34;item-name&#34;&gt;prettyprinter&lt;/a&gt;

  
  (&lt;a href=&#34;https://hackage.haskell.org/package/prettyprinter&#34;&gt;Hackage&lt;/a&gt;)
&lt;/h1&gt;&lt;p&gt;Pretty printer loosely based on Wadler&#39;s &lt;a href=&#34;https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf&#34;&gt;&amp;quot;A Prettier Printer&amp;quot;&lt;/a&gt; paper.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;kw&#34;&gt;let&lt;/span&gt; prettyType &lt;span class=&#34;fu&#34;&gt;=&lt;/span&gt; align &lt;span class=&#34;fu&#34;&gt;.&lt;/span&gt; sep &lt;span class=&#34;fu&#34;&gt;.&lt;/span&gt; zipWith (&lt;span class=&#34;fu&#34;&gt;&amp;lt;+&amp;gt;&lt;/span&gt;) (&lt;span class=&#34;st&#34;&gt;&amp;quot;::&amp;quot;&lt;/span&gt; &lt;span class=&#34;fu&#34;&gt;:&lt;/span&gt; repeat &lt;span class=&#34;st&#34;&gt;&amp;quot;-&amp;gt;&amp;quot;&lt;/span&gt;)
    prettySig name ty &lt;span class=&#34;fu&#34;&gt;=&lt;/span&gt; pretty name &lt;span class=&#34;fu&#34;&gt;&amp;lt;+&amp;gt;&lt;/span&gt; prettyType ty
&lt;span class=&#34;kw&#34;&gt;in&lt;/span&gt;  prettySig &lt;span class=&#34;st&#34;&gt;&amp;quot;example&amp;quot;&lt;/span&gt; [&lt;span class=&#34;st&#34;&gt;&amp;quot;Int&amp;quot;&lt;/span&gt;, &lt;span class=&#34;st&#34;&gt;&amp;quot;Bool&amp;quot;&lt;/span&gt;, &lt;span class=&#34;st&#34;&gt;&amp;quot;Char&amp;quot;&lt;/span&gt;, &lt;span class=&#34;st&#34;&gt;&amp;quot;IO ()&amp;quot;&lt;/span&gt;]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;co&#34;&gt;-- Output for wide enough formats:&lt;/span&gt;
&lt;span class=&#34;ot&#34;&gt;example ::&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Int&lt;/span&gt; &lt;span class=&#34;ot&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Bool&lt;/span&gt; &lt;span class=&#34;ot&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Char&lt;/span&gt; &lt;span class=&#34;ot&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;IO&lt;/span&gt; ()

&lt;span class=&#34;co&#34;&gt;-- Output for narrow formats:&lt;/span&gt;
&lt;span class=&#34;ot&#34;&gt;example ::&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Int&lt;/span&gt;
        &lt;span class=&#34;ot&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Bool&lt;/span&gt;
        &lt;span class=&#34;ot&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;Char&lt;/span&gt;
        &lt;span class=&#34;ot&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;IO&lt;/span&gt; ()&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2&gt;Pros&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;Uses &lt;code&gt;Text&lt;/code&gt; instead of &lt;code&gt;String&lt;/code&gt; for better performance&lt;/li&gt;&lt;/p&gt;&lt;p&gt;&lt;li&gt;Supports annotations (coloring, mouse-over hovers, adding URLs, etc.)&lt;/li&gt;&lt;/p&gt;&lt;p&gt;&lt;li&gt;Excellent &lt;a href=&#34;https://hackage.haskell.org/package/prettyprinter-1.1.1/docs/Data-Text-Prettyprint-Doc.html&#34;&gt;docs&lt;/a&gt; and &lt;a href=&#34;https://github.com/quchen/prettyprinter/tree/master/prettyprinter/src/Data/Text/Prettyprint/Doc/Render/Tutorials&#34;&gt;tutorial&lt;/a&gt;&lt;/li&gt;&lt;/p&gt;&lt;p&gt;&lt;li&gt;Has &lt;code&gt;compat&lt;/code&gt; packages to help migrate from other pretty printing libraries&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;&lt;h2&gt;Cons&lt;/h2&gt;&lt;ul&gt;&lt;/ul&gt;&lt;h2&gt;Ecosystem&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/prettyprinter&#34;&gt;prettyprinter&lt;/a&gt; - the core package&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/prettyprinter-ansi-terminal&#34;&gt;prettyprinter-ansi-terminal&lt;/a&gt; - a renderer suitable for ANSI terminal output including colors&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/prettyprinter-compat-wl-pprint&#34;&gt;prettyprinter-compat-wl-pprint&lt;/a&gt; a drop-in compatibility layer for previous users of &lt;code&gt;wl-pprint&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/prettyprinter-compat-ansi-wl-pprint&#34;&gt;prettyprinter-compat-ansi-wl-pprint&lt;/a&gt; - the same, but for previous users of &lt;code&gt;ansi-wl-pprint&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/prettyprinter-compat-annotated-wl-pprint&#34;&gt;prettyprinter-compat-annotated-wl-pprint&lt;/a&gt; - the same, but for previous users of &lt;code&gt;annotated-wl-pprint&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://hackage.haskell.org/package/prettyprinter-convert-ansi-wl-pprint&#34;&gt;prettyprinter-convert-ansi-wl-pprint&lt;/a&gt; - a converter, not a drop-in replacement, for documents generated by &lt;code&gt;ansi-wl-pprint&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See &lt;a href=&#34;https://github.com/quchen/prettyprinter/blob/master/README.md#the-prettyprinter-family&#34;&gt;the README&lt;/a&gt; for more information.&lt;/p&gt;
</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/pretty-printing-uhierj0c#item-g3bsxslp"/></entry><entry><id>atkyw60j</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">pretty</title><updated>2016-07-11T09:28:17Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;pretty&lt;/span&gt;

  
  (&lt;a href=&#34;https://hackage.haskell.org/package/pretty&#34;&gt;Hackage&lt;/a&gt;)
&lt;/h1&gt;&lt;p&gt;Pretty printer based on John Hughes&#39; &lt;a href=&#34;http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.38.8777&#34;&gt;&amp;quot;The Design of a Pretty-printing Library&amp;quot;&lt;/a&gt; paper and improved by Simon Peyton Jones.&lt;/p&gt;
&lt;h2&gt;Pros&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;Few dependencies (and all of them ship with GHC)&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;&lt;h2&gt;Cons&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;Uses &lt;code&gt;String&lt;/code&gt; instead of &lt;a href=&#34;https://hackage.haskell.org/package/text&#34;&gt;text&lt;/a&gt; which causes poor performance when formatting a large amount of output&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/pretty-printing-uhierj0c#item-atkyw60j"/></entry><entry><id>pv0594vc</id><title xmlns:ns="http://www.w3.org/2005/Atom" ns:type="text">boxes</title><updated>2016-07-11T09:28:08Z</updated><content xmlns:ns="http://www.w3.org/2005/Atom" ns:type="html">&lt;h1&gt;  &lt;span class=&#34;item-name&#34;&gt;boxes&lt;/span&gt;

  
  (&lt;a href=&#34;https://hackage.haskell.org/package/boxes&#34;&gt;Hackage&lt;/a&gt;)
&lt;/h1&gt;&lt;p&gt;Lays out text in two dimensions, using a simple box model.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;&lt;span class=&#34;ot&#34;&gt;print_table ::&lt;/span&gt; [[&lt;span class=&#34;dt&#34;&gt;String&lt;/span&gt;]] &lt;span class=&#34;ot&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&#34;dt&#34;&gt;IO&lt;/span&gt; ()
print_table rows &lt;span class=&#34;fu&#34;&gt;=&lt;/span&gt; printBox &lt;span class=&#34;fu&#34;&gt;$&lt;/span&gt; hsep &lt;span class=&#34;dv&#34;&gt;2&lt;/span&gt; left (map (vcat left &lt;span class=&#34;fu&#34;&gt;.&lt;/span&gt; map text) (transpose rows))&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&#34;sourceCode&#34;&gt;&lt;pre class=&#34;sourceCode&#34;&gt;&lt;code class=&#34;sourceCode&#34;&gt;Mercoxit     335.67
Arkonor      276.15
Bistot       214.30&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&#34;http://www.tedreed.info/programming/2012/06/02/how-to-use-textprettyprintboxes/&#34;&gt;Source&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Pros&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;Few dependencies (&lt;a href=&#34;https://hackage.haskell.org/package/base&#34;&gt;base&lt;/a&gt; and &lt;a href=&#34;https://hackage.haskell.org/package/split&#34;&gt;split&lt;/a&gt;)&lt;/li&gt;&lt;/p&gt;&lt;p&gt;&lt;li&gt;Simple model&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;&lt;h2&gt;Cons&lt;/h2&gt;&lt;ul&gt;&lt;p&gt;&lt;li&gt;Limited formatting configuration&lt;/li&gt;&lt;/p&gt;&lt;p&gt;&lt;li&gt;No examples/tutorial&lt;/li&gt;&lt;/p&gt;&lt;/ul&gt;</content><link xmlns:ns="http://www.w3.org/2005/Atom" ns:href="https://guide.aelve.com/haskell/pretty-printing-uhierj0c#item-pv0594vc"/></entry></feed>