Skip to content
Compile-time checked printf
Haskell Nix Other
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
include
parser
src
tests/printf
.ghci
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
Setup.hs
hie.sh
package.yaml
shell.nix
th-printf.cabal

README.md

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.

You can’t perform that action at this time.