Presentation is loading. Please wait.

Presentation is loading. Please wait.

Workshop: Towards Highly Portable Software Jakarta, 20 – 23 January 2003 Diselenggarakan oleh Universitas IndonesiaUniversitas Indonesia Using Pretty Printing.

Similar presentations


Presentation on theme: "Workshop: Towards Highly Portable Software Jakarta, 20 – 23 January 2003 Diselenggarakan oleh Universitas IndonesiaUniversitas Indonesia Using Pretty Printing."— Presentation transcript:

1 Workshop: Towards Highly Portable Software Jakarta, 20 – 23 January 2003 Diselenggarakan oleh Universitas IndonesiaUniversitas Indonesia Using Pretty Printing Combinator Dr. Ir. I.S.W.B. Prasetyawishnu@cs.uu.nl A. Azurat S.Kom.ade@cs.uu.nl

2 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” height width last line

3 3 PP Document The basic building blocks for pretty-printing are PP documents (of type PP_Doc ). You obtain PP documents either by : 1.using the primitive text 2.combining PP documents with the pretty-printing operators.

4 4 Basic interface InterfaceComments empty The empty PP document and null element for the operations beside and above text s Converts the string s into a PP document render ppd pw Prints the PP document ppd (to IO () ) in a page pw (>=0) wide

5 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 6 Basic Combinator x >|< y x beside y x >-< y x above y

7 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 ># |<, what is the difference ? )

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

9 9


Download ppt "Workshop: Towards Highly Portable Software Jakarta, 20 – 23 January 2003 Diselenggarakan oleh Universitas IndonesiaUniversitas Indonesia Using Pretty Printing."

Similar presentations


Ads by Google