[Haskell-cafe] Reducing code for efficient ShowS

Sean Leather leather at cs.uu.nl
Fri Sep 5 18:28:14 EDT 2008


> Why not use the dlist library:
>
>    http://hackage.haskell.org/cgi-bin/hackage-scripts/package/dlist
>
> 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.

Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080906/bd39278e/attachment.htm


More information about the Haskell-Cafe mailing list