Skip to content

Latest commit

 

History

History
26 lines (17 loc) · 734 Bytes

README.md

File metadata and controls

26 lines (17 loc) · 734 Bytes

th-printf th-printf th-printf

printf QuasiQuoters

Usage

import Language.Haskell.Printf

-- String interpolation
[s|Hello, %s!|] "Jeff" -- "Hello, Jeff!"

-- Text interpolation
[s|Hello, %q!|] (Data.Text.Lazy.pack "Jeff") -- "Hello, Jeff!"

-- Width specifiers
[s|%010d|] 1977 -- "0000001977"

-- Different radices
[s|%d, %x, %o, %#x, %#o|] 100 100 100 100 100 -- "100, 64, 144, 0x64, 0144"

-- Variable-width formatting
[s|%0*d|] 5 10 -- "00010"

There's also another format specifier %?, which accepts any Showable datatype.