[Haskell-beginners] Why ShowS?

Brandon Allbery allbery.b at gmail.com
Thu Aug 11 07:16:25 CEST 2011


On Wed, Aug 10, 2011 at 22:34, Christopher Howard <
christopher.howard at frigidcode.com> wrote:

> One of the reasons I asked: I was wondering if Haskell already had a
> library that would take an Int/Integer and convert it to the string
> representations of other bases; or if this was a chore that still needed to
> be taken care of by someone. I found the Numeric module, but then see that
> all relevant functions return this weird "ShowS" instead of a String. So...
> is that how everyone likes it? Or is there another module people use for
> base conversion...?


I think it isn't used often enough for anyone to bother reworking it,
especially since you can sidestep the ShowS stuff by invoking e.g. (showHex
myNum "") which nets you an ordinary String.  (Parse this as ((showHex
myNum) ""), where (showHex myNum) produces a ShowS (function from String to
String) which is then applied to ("").)  You could also cheat if you have
something to append to the result of (showHex) by passing that instead of
("").

-- 
brandon s allbery                                      allbery.b at gmail.com
wandering unix systems administrator (available)     (412) 475-9364 vm/sms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110811/cfc43a8b/attachment.htm>


More information about the Beginners mailing list