https://github.com/pikajude/th-printf
Compile-time checked printf
https://github.com/pikajude/th-printf
haskell printf
Last synced: 3 months ago
JSON representation
Compile-time checked printf
- Host: GitHub
- URL: https://github.com/pikajude/th-printf
- Owner: pikajude
- License: mit
- Created: 2013-10-07T16:27:08.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2023-08-03T04:11:38.000Z (over 2 years ago)
- Last Synced: 2025-10-21T13:55:48.551Z (3 months ago)
- Topics: haskell, printf
- Language: Haskell
- Size: 175 KB
- Stars: 14
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# th-printf  [](https://hackage.haskell.org/package/th-printf)
printf QuasiQuoters
## Usage
```haskell
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 `Show`able datatype.