90 likes | 250 Views
Using Pretty Printing Combinator. Dr. Ir. I.S.W.B. Prasetya wishnu@cs.uu.nl A. Azurat S.Kom. ade@cs.uu.nl. Pretty Printing Library . How to pretty print some output nicely based on some layout → use lay out combinator (use UU_Pretty Library) Run hugs with option :
E N D
Using Pretty Printing Combinator Dr. Ir. I.S.W.B. Prasetya wishnu@cs.uu.nl A. Azurat S.Kom. ade@cs.uu.nl
Pretty Printing Library How to pretty print some output nicely based on some layout → use lay out combinator (use UU_Pretty Library) Run hugs with option : hugs -98 +o –P:”c:\tools\UU.lib” width height last line
PP Document • The basic building blocks for pretty-printing are PP documents (of type PP_Doc). • You obtain PP documents either by : • using the primitive text • combining PP documents with the pretty-printing operators.
example We are ready to try out the first examples: > tenplus = "01234567890 ha!" > t_text = render (text tenplus) 15 whose output is 0123456789 ha!. But: > t_error = render (text tenplus) 10 will result in <************>, because the page is not wide enough. The number of characters of the output line is the actual width of the input string.
example Horizontal (beside) and vertical (above) composition are the principal combinators used to build more complex documents. For example: > hello = "hello" > world = "world!" > h_beside_w = hello >|< world > t_beside = render h_beside_w 20 (Hint: Try to use >#< instead of >|< , what is the difference ? )
Exercise Run hugs with option : -98 +o –P:”c:\tools\UU.lib”