import Text.Printf(printf)
disp = putStr . format " " (printf "%.2f")
>>> format "{} + {} = {}" 2 2 4
2 + 2 = 4
You can use arbitrary formatters:
>>> format "0x{} + 0x{} = 0x{}" (hexF 130) (hexF 270) (hexF (130+270))
0x82 + 0x10e = 0x190
>>> format "{:s}, {:d}, {:.4f}" "hello" 123 pi
"hello, 123, 3.1416"
>>> format "{1:s}, {0:d}, {2:.4f}" 123 "hello" pi
"hello, 123, 3.1416"
>>> format "{:s} {:d} {pi:.4f}" "hello" 123 ("pi" := pi)
"hello, 123, 3.1416"
See Format to learn more about format string syntax.
See FormatArg to learn how to derive FormatArg for your own
data types.