[Haskell-cafe] Re: Pure Haskell Printf

Jon Fairbairn Jon.Fairbairn at cl.cam.ac.uk
Tue Nov 16 06:21:10 EST 2004


On 2004-11-16 at 11:42+0100 Peter Simons wrote:
> Henning Thielemann writes:
> 
>  >> One advantage is that you need to type fewer characters.
> 
>  > I know memory is expensive, that's why only the last two
>  > digits of year numbers are stored. :-]
> 
> I understand what you're getting at -- and I find it
> annoying, too, when people sacrifice robustness for comfort.
> 
> I'm not sure, though, whether this is the case here, because
> vsnprintf in Haskell still is type-safe.


Not statically, though, surely? 

> vsprintf "%d, your age is %s\n" "John" (10::Integer)

is type incorrect, but won't be reported at compile time. At
least I can't see how it could be, given that the string
can't be dissected at compile time.

>  > You can save even more characters:
> 
>  > msg  = verb "i = " . shows 12 . verb "\tj = " $ "test"
> 
> Right! One more reason to use ShowS-style. :-)

and that really is type safe.


-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Haskell-Cafe mailing list