antalsz / th-printf

Compile-time checked printf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:MIT License


Languages

Language:Haskell 98.9%Language:Nix 1.1%