Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Marc Weber <marco-oweber <at> gmx.de>
Subject: ANN: Printf-TH
Newsgroups: gmane.comp.lang.haskell.cafe
Date: Saturday 14th June 2008 18:08:28 UTC (over 9 years ago)
Igloo (Ian Lynagh) allowed me kindly taking over maintainance on his
printf library using template haskell written in 2003. I've updated it
so that it compiles with ghc-6.8.2.
You can get it from hackage:
 http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Printf-TH

usage looks like this:

{-# OPTIONS_GHC -XTemplateHaskell #-}
...
import Language.Haskell.TH.Syntax
import Text.Printf.TH (printf)

...
            putStrLn $ $(printf "Foo %H bar") (Just 5)
            putStrLn $ $(printf "%6d") 1
            putStrLn $ $(printf "%6d") (-1)

Short Explanation:
$(printf "%d") will be replaced by a auto generated function taking an int
etc

Benefit:
Wrong arg types or wrong printf arg count will result in compile time
errors.

Enjoy
Marc Weber
 
CD: 3ms