[Haskell-cafe] untyped printf
Henning Thielemann
lemming at henning-thielemann.de
Fri Dec 4 20:08:15 UTC 2020
On Fri, 4 Dec 2020, Ben Franksen wrote:
> Wow, that simple. Thanks Henning, my untangled brain feels a lot better :-)
I tangled my brain because I expected that it must be possible in Haskell
98 ...
... and actually it is:
import Text.Printf (PrintfType, printf)
type Value = Int
printfv :: (PrintfType printf) => String -> [Value] -> printf
printfv fmt [] = printf fmt
printfv fmt (x:xs) = printfv fmt xs x
format :: String -> [Value] -> String
format fmt = printfv fmt . reverse
More information about the Haskell-Cafe
mailing list