Skip to content

pikajude/th-printf

Repository files navigation

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.

About

Compile-time checked printf

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published