HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduleturtle-1.6.2Haskell2010

Turtle.Format

Minimalist implementation of type-safe formatted strings, borrowing heavily from the implementation of the formatting package.

Example use of this module:

Example3 expressions
:set -XOverloadedStringsimport Turtle.Formatformat ("This is a "%s%" string that takes "%d%" arguments") "format" 2"This is a format string that takes 2 arguments"

A Format string that takes no arguments has this type:

"I take 0 arguments" :: Format r r

format "I take 0 arguments" :: Text
Example1 expression
format "I take 0 arguments""I take 0 arguments"

A Format string that takes one argument has this type:

"I take "%d%" arguments" :: Format r (Int -> r)

format ("I take "%d%" argument") :: Int -> Text
Example1 expression
format ("I take "%d%" argument") 1"I take 1 argument"

A Format string that takes two arguments has this type:

"I "%s%" "%d%" arguments" :: Format r (Text -> Int -> r)

format ("I "%s%" "%d%" arguments") :: Text -> Int -> Text
Example1 expression
format ("I "%s%" "%d%" arguments") "take" 2"I take 2 arguments"
Contents
  1. Format
  2. Parameters
  3. Utilities
Synopsis
  • Packageturtle-1.6.2
  • Exports19
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFormat.hs

Format

valueprintf :: MonadIO io => Format (io ()) r -> r

Print a Format string to standard output (without a trailing newline)

Example1 expression
printf ("Hello, "%s%"!\n") "world"Hello, world!
valueeprintf :: MonadIO io => Format (io ()) r -> r

Print a Format string to standard err (without a trailing newline)

Example1 expression
eprintf ("Hello, "%s%"!\n") "world"Hello, world!

Parameters

valuex :: Format r (Word -> r)

Format a Word value as an unsigned hexadecimal number (without a leading "0x")

Example1 expression
format x 25"19"
valuee :: Format r (Double -> r)

Format a Double using scientific notation with 6 digits of precision

Example1 expression
format e 25.1"2.510000e1"
valueg :: Format r (Double -> r)

Format a Double using decimal notation for small exponents and scientific notation for large exponents

Example3 expressions
format g 25.1"25.100000"format g 123456789"1.234568e8"format g 0.00000000001"1.000000e-11"

Utilities