Re: [Haskell-cafe] Reducing code for efficient ShowS

2008-09-05 Thread wren ng thornton
Sean Leather wrote: There's the obvious approach that's described in every tutorial, book, and research paper (for didactic purposes, of course). ex1 = ( ++ show n ++ ++ s ++ ) It's pretty concise, but it's horribly inefficient due to the use of (++). Then, there's the ShowS approach.

Re: [Haskell-cafe] Reducing code for efficient ShowS

2008-09-05 Thread Sean Leather
Why not use the dlist library: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dlist With something like (untested code): xs +++ ys = showsxs `append` showsys x .++ ys = showChar x `cons` showsys xs ++. y = showsxs `snoc` showChar y ext3' =

Re: [Haskell-cafe] Reducing code for efficient ShowS

2008-09-05 Thread wren ng thornton
Sean Leather wrote: Why not use the dlist library: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dlist With something like (untested code): xs +++ ys = showsxs `append` showsys x .++ ys = showChar x `cons` showsys xs ++. y = showsxs `snoc`

Re: [Haskell-cafe] Reducing code for efficient ShowS

2008-09-05 Thread Sean Leather
That's an interesting idea. It appears to use the same idea as ShowS, but more generally with lists and not just strings. The difference-list approach to solving the appending problem is classic. There's a variant for unification-based logic languages as well. Both are functional takes on