GHC: Ticket Query
http://ghc.haskell.org/trac/ghc/query?component=libraries%2Fpretty&milestone=Not+GHC&group=status&order=priority
The Glasgow Haskell Compileren-USGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/query?component=libraries%2Fpretty&milestone=Not+GHC&group=status&order=priority
Trac 1.0.1
http://ghc.haskell.org/trac/ghc/ticket/1217
http://ghc.haskell.org/trac/ghc/ticket/1217#1217: Add zeroText to Text.PrettyPrint.HughesPJTue, 13 Mar 2007 02:43:46 GMTneil<p>
I propose the addition of Text.PrettyPrint.HughesPJ.zeroText :: String -> Doc
</p>
<p>
This function is essential for outputting HTML which contains textual markup which occupies no space. For an example of it's use see: <a class="ext-link" href="http://darcs.haskell.org/yhc/src/libraries/core/Yhc/Core/Html.hs"><span class="icon"></span>http://darcs.haskell.org/yhc/src/libraries/core/Yhc/Core/Html.hs</a>
</p>
<p>
One week for discussion
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/1217#changelog
http://ghc.haskell.org/trac/ghc/ticket/4377
http://ghc.haskell.org/trac/ghc/ticket/4377#4377: sizedText function for Text.PrettyPrintThu, 07 Oct 2010 18:24:05 GMTlerkok<p>
The <tt>Text.PrettyPrint</tt> library has a <tt>text</tt> function for converting ordinary strings to documents. This function takes the length of the string to be its final size. However, there are use cases where the actual length of this string and the "virtual" length of the document it represents are not necessarily the same. This use case comes up in cases where the resulting "Doc" is rendered to String and a further processor works on that particular string with its own built-in assumptions about how things should be laid out. (In our case, we produce Isabelle/HOL code from Cryptol, which gets rendered by the Isabelle theorem prover. These strings are the tags that correspond to Isabelle's own escape sequences for certain theory specific logical symbols.)
</p>
<p>
To remedy this, adding a function "sizedText" to the library would suffice:
</p>
<pre class="wiki">sizedText :: Int -> String -> Doc
sizedText l s = TextBeside (Str s') l Empty
where s' = s ++ take (l - length s) (repeat ' ')
</pre><p>
Unfortunately this function can <strong>not</strong> be defined outside the <tt>PrettyPrint</tt> library itself, This is because the <tt>TextBeside</tt> constructor is not exported, and there seems to be no other way of accessing the length field otherwise.
</p>
<p>
Note that in the above code the user given length <tt>l</tt> can be larger or smaller than the actual length of the string <tt>s</tt>; so the first argument to <tt>take</tt> can be positive or negative. In either case the function does the right thing for our use case: If smaller, you get the original string; which messes up the ASCII output a bit but is the right thing to the for the target processor; if larger, then it gets padded with space at the end appropriately to get the ASCII looking right as well.
</p>
<p>
Our current workaround for this issue is to replicate the library code ourselves and add this function on top, which is a kludge at best that we'd like to avoid.
</p>
<p>
The function <tt>sizedText</tt> satisfies the law:
</p>
<pre class="wiki"> sizedText (length s) s = text s
</pre><p>
and hence agrees with the existing <tt>text</tt> function for ordinary usage.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4377#changelog
http://ghc.haskell.org/trac/ghc/ticket/4378
http://ghc.haskell.org/trac/ghc/ticket/4378#4378: Add IsString and Monoid instances for DocFri, 08 Oct 2010 07:35:29 GMTbasvandijk<p>
The proposal is to add the following to <tt>Text.PrettyPrint.HughesPJ</tt>:
</p>
<pre class="wiki">instance IsString Doc where
fromString = text
instance Monoid Doc where
mempty = empty
mappend = (<>)
</pre><p>
See the attached patch.
</p>
Resultshttp://ghc.haskell.org/trac/ghc/ticket/4378#changelog