Re: [Haskell-cafe] Pure Haskell Printf

2004-11-16 Thread Henning Thielemann
On Mon, 15 Nov 2004, John Goerzen wrote: Here are some examples: vsprintf Hello Hello vsprintf Hello, %s\n John Hello, John\n vsprintf %s, your age is %d\n John (10::Integer) John, your age is 10\n sprintfAL %(name)s, your age is %(age)d\n [(name, v John), (age, v

[Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Peter Simons
Henning Thielemann writes: Variable length argument lists are really a mess. Why are people so keen on them? One advantage is that you need to type fewer characters. It's, well, not _that_ important, I'll readily admit. :-) But vsnprintf i = %d;\tj = %s 12 test is more compact than any

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Henning Thielemann
On 16 Nov 2004, Peter Simons wrote: Henning Thielemann writes: Variable length argument lists are really a mess. Why are people so keen on them? 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

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Keean Schupke
At the risk of getting off topic... the reason 'C' has printf is because it is not polymorphic. Printf is a hack to allow different types to be printed out, such that they did not need printInt, printFloat etc. Remember C is typesafe, so the only way they could do this was to pass the first

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Andreas Rossberg
Keean Schupke wrote: Remember C is typesafe In which parallel universe? -- Andreas Rossberg, [EMAIL PROTECTED] Let's get rid of those possible thingies! -- TB ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Jon Fairbairn
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

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Keean Schupke
Andreas Rossberg wrote: Keean Schupke wrote: Remember C is typesafe In which parallel universe? I of course meant strongly-typed, you cannot pass a pointer to an int where a pointer to a float is required ... modern C compilers require you to explicitly cast. Where it fell down was all that

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Keean Schupke
Actually it can be statically checked, as the string is a constant, we can lift it to a type (at the moment we would have to use template haskell - but there is no reason the compiler cannot be a little more aggresive in applying functions to constants at compile time, in which case we can use

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread David Roundy
On Tue, Nov 16, 2004 at 12:21:41PM +0100, Henning Thielemann wrote: The function MissingH.Printf.sprintf is probably the better choice, but one could even replace [Value] by [String]. The conversion from any type to String can be easily done using 'show' by the caller. Though it gives the

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Ben Rudiak-Gould
Keean Schupke wrote: At the risk of getting off topic... the reason 'C' has printf is because it is not polymorphic. Printf is a hack to allow different types to be printed out, such that they did not need printInt, printFloat etc. Many language have printf-like functions despite not satisfying

[Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Peter Simons
Jon Fairbairn writes: vsprintf %d, your age is %s\n John (10::Integer) is type incorrect, but won't be reported at compile time. Hmmm. Right. You'd need Template Haskell for that. I see. Peter ___ Haskell-Cafe mailing list [EMAIL PROTECTED]

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Matthew Walton
Ben Rudiak-Gould wrote: Keean Schupke wrote: At the risk of getting off topic... the reason 'C' has printf is because it is not polymorphic. Printf is a hack to allow different types to be printed out, such that they did not need printInt, printFloat etc. Many language have printf-like

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Andreas Rossberg
Keean Schupke wrote: I of course meant strongly-typed, you cannot pass a pointer to an int where a pointer to a float is required ... modern C compilers require you to explicitly cast. According to the C standard, void f(float *p) { *p + 1.0; } void g(void *p) { f(p); } void h(int n) {

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread MR K P SCHUPKE
Of course you can do intertationalisation with show... There is a paper on using type classes to define implicit confugurations, perhasps someone can provide the reference? This can be used to nicely redefine show... Ill see if I cant dig out an example. Keean.

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Scott Turner
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

[Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread John Goerzen
On 2004-11-16, Henning Thielemann [EMAIL PROTECTED] wrote: On 16 Nov 2004, Peter Simons wrote: Yes and no. It can't be checked statically if the number of placeholders matches the number of arguments. It can't be checked statically if the types of placeholders match the types of arguments. It

[Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread John Goerzen
On 2004-11-16, Peter Simons [EMAIL PROTECTED] wrote: 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. In this particular case,

[Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread John Goerzen
On 2004-11-16, Jon Fairbairn [EMAIL PROTECTED] wrote: On 2004-11-16 at 11:42+0100 Peter Simons wrote: 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

Re: [Haskell-cafe] Re: Pure Haskell Printf

2004-11-16 Thread Keith Wansbrough
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