[Haskell-cafe] Re: Pure Haskell Printf

Jan-Willem Maessen Janwillem.Maessen at Sun.COM
Wed Nov 17 11:38:53 EST 2004



Scott Turner wrote:

>On 2004 November 16 Tuesday 06:42, Jérémy Bobbio wrote:
>  
>
>>There is a probleme with ShowS though: it is not internationalizable at
>>all.  Strings like printf's or with any kind of variable substitution is
>>required for proper internationalization / localization.
>>    
>>
>Printf is not adequate for internationalization either, because word (and thus 
>parameter) ordering may vary among languages.  Note that MissingH.Printf 
>addresses this with a feature which supports keys in format items, e.g. 
>%(item1)s.
>
This is what it boils down to for me.  A post by Malcolm Wallace to one 
of the Haskell lists a few years back convinced me that:

Internationalization is a killer application for printf-style 
format-string-based functions.

I have seen approximately 32767 different proposals for printf with 
strong static typechecking, using anything from specialized data types 
to depedently-typed functions to compile-time reflection.

None of these appears to be able to solve the simple problem of allowing 
localization (or general fiddling with the formatting) without 
recompiling and relinking.  In that respect there will always be a place 
for dynamically-checked printf, and John's library really seems to be 
doing The Right Thing.

I remain much more skeptical that there's a need for a 
statically-checked printf which uses format strings.  ShowS and related 
approaches work pretty well in my experience (though it'd be nice to see 
standardized support for flexible number formatting).

A Challenge To The Type System Hackers: Is there a way to get the best 
of both worlds?  To do static checking on format strings when they're 
available, but fall back to dynamic checking when they are not?  Perhaps 
we provide a canonical format string, or use some other sort of hackery, 
and then check the actual string dynamically.

-Jan-Willem Maessen




More information about the Haskell-Cafe mailing list