From: Robert Feldt Date: 2002-01-14T19:44:19+09:00 Subject: Re: MetaRuby : RubySchema.rb howto? On Mon, 14 Jan 2002, Tanaka Akira wrote: > > if (condition) statement end > > Yes. There is no such way yet. But I think there is no big > difficulty to implement it. > I'll take a better look at your code. I'd like to merge my PPDoc stuff with it (since I find it easier than having to write pp.indent { } etc, but maybe I just have to get used to it to like it). > > even if it fits on a line. But I may be wrong cause I only took a brief > > look at prettyprint and saw it was based on Wadler's prettyprint libs > > (which may also give it exponential alg complexity; anyone checked > > that?). I may have jumped to conclusions... > > I think the complexity is linear, maybe. > Ok, then there are some simplifications because the standard funcprog pretty-printing libraries are known to have non-linear complexities. > Note that now I interested in another pretty printing algorithm: > Pablo R. Azero, S. Doaitse Swierstra. > Optimal Pretty-Printing Combinators, 1998. > http://www.cs.ruu.nl/groups/ST/Software/PP/ > I've had some experience with it. It's the most powerful library but can be the slowest. You might also want to check out Olaf Chitil: Pretty Printing with Lazy Dequeues Preliminary Proceedings of the 2001 ACM SIGPLAN Haskell Workshop, Firenze, Italy, Universiteit Utrecht UU-CS-2001-23, 2 September 2001, pp. 183-201. which is an implementation of Oppen's pretty printing algorithm in Haskell. Oppens alg is based on dynamic programming and is fast. I don't think it is as expressive as Azero's approach though. One thing I'd like to see that I haven't seen in any of the funcprog libs are BalancedGroup which tries to print the group on one line but if its not possible splits it so that roughly half of it goes on this line and half of it on the next one etc. Instead of [1, 2, 3, 4, 5, 6, 7] you could then get [1, 2, 3, 4, 5, 6, 7] which I think is a bit nicer. Would it be possible? BTW, do you support indented groups like the one for the elements above that indent the position of the first element of the second line (5) to the same as the first element of the group on the first line (1)? I'll try and see if I can construct your prettyprint object from the text templates of PPDoc. Regards, Robert