2 points about language

Alastair David Reid reid@cs.utah.edu
24 Aug 2001 12:32:02 -0600


> Rewriting (x++y)++z to x++(y++z) so one, for example, doesn't need
> all the kludge in the Pretty printer?

Note that the "kludge" in the pretty-printer is primarily to handle 
cases where the ++'s do not occur next to each other in the static text.
For example, I might glue together a tree of strings using code like this:

  data Tree a = Node a [Tree a]

  glue :: Tree String -> String
  glue (Node x ts) = x ++ concatMap glue ts

The uses of ++ and concatMap look just fine - at each node I'm
appending strings in the efficient right-associative manner.  But my
code still takes quadratic time (worst case) because the ++ gets
repeated at each level in the tree.

I think this is the real problem being fixed in Pretty, ShowS, etc.

-- 
Alastair Reid        reid@cs.utah.edu        http://www.cs.utah.edu/~reid/