1 / 9

Using Pretty Printing Combinator

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 :

edie
Download Presentation

Using Pretty Printing Combinator

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using Pretty Printing Combinator Dr. Ir. I.S.W.B. Prasetya wishnu@cs.uu.nl A. Azurat S.Kom. ade@cs.uu.nl

  2. 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

  3. 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.

  4. Basic interface

  5. 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.

  6. Basic Combinator

  7. 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 ? )

  8. Exercise Run hugs with option : -98 +o –P:”c:\tools\UU.lib”

More Related