[Haskell-cafe] Reducing code for efficient ShowS
leather at cs.uu.nl
Fri Sep 5 18:28:14 EDT 2008
> Why not use the dlist library:
> With something like (untested code):
> > xs +++ ys = shows xs `append` shows ys
> > x .++ ys = showChar x `cons` shows ys
> > xs ++. y = shows xs `snoc` showChar y
> > ext3' = toList $ '(' .++ n +++ ' ' .++ s ++. ')'
I think you're missing the fromList parts among other things.
That's an interesting idea. It appears to use the same idea as ShowS, but
more generally with lists and not just strings.
I think there's an added benefit to not having to remember the the type of
the value being appended. It's one of the more convenient things about many
dynamically typed languages. So, I would still vote for the class-based
method, so that I can use (.+.) for both Char and everything else.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe