[Haskell-cafe] Re: Pure Haskell Printf

John Goerzen jgoerzen at complete.org
Tue Nov 16 09:50:48 EST 2004


On 2004-11-16, Henning Thielemann <iakd0 at clusterf.urz.uni-halle.de> 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 is not possible to
> create functions with more than one variable length parameter lists.

That's a particular problem, since this was one of the motivations for
getting a printf out there.  It makes a very nice way to produce nice
column-aligned data from a variety of numeric and string sources, and
provides a good deal of control over numeric output formats, too.

If I encounter %07.3f, I can't just do a read on a string passed to me,
hoping that I'd get a valid Double (or Rational or whatever).  One of
the annoying things is that show on a Rational produces a value that is
incompatible with show on a Double, and the read functions for these two
types can't understand each other's string formats.  (Urg.)

>> and pass a function (String -> a) to vsnprintf which does
>> the lookup. I'm not sure how having different types of
>> values in the dictionary plays into this, though.

There is a function like that in the MissingH.Printf source, but it is
not exported at present (rather it is used to support the association
list and FiniteMap versions of this feature).  It could easily be
exported, though.

-- John




More information about the Haskell-Cafe mailing list