[Haskell-cafe] Pure Haskell Printf

John Goerzen jgoerzen at complete.org
Mon Nov 15 16:49:42 EST 2004

(Sorry for the crosspost; I'm not sure which list this should go to.)

I've just completed a pure-Haskell printf.  Docs at [1], download at

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 (10::Integer))]
> "John, your age is 10\n"

I have more examples available at the doc page[1].

I used Ian Lynagh's Printf.Printer module to do the actual formatting (I
converted it away from TH first).  I got the idea for simulating
handling variable numbers of function arguments from the haskell-xml-rpc

I would appreciate comments/critiques.

-- John

[1] http://gopher.quux.org:70/devel/missingh/html/MissingH.Printf.html
[2] http://gopher.quux.org:70/devel/missingh

More information about the Haskell-Cafe mailing list