make Text.Printf extensible, more flexible

John Meacham john at repetae.net
Mon May 15 18:02:05 EDT 2006


I was wondering if we could make Text.Printf extensible to user defined
types.

as far as I can tell, all that is needed is to export PrintfArg so that
users can define new instances. it would also be nice if UPrintf could
be switched from the current union type to a higher order function,
since the only thing UPrintf is used for is formating strings. I am
thinking something like

newtype UPrintf = UPrintf (UFmt -> ShowS)

data Adjustment = LeftAdjust | ZeroPad

data UFmt = UFmt {
        fmtAdjust :: Maybe Adjustment,
        fmtFieldWidth :: Maybe Int,
        fmtPrecision :: Maybe Int,
        fmtCharacter :: Char
 }


so, a UPrintf is just a function that takes a parsed formating string
and prints the appropriate string.


        John


-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Libraries mailing list