stringfmt
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Fmt.Text

Description

Text formatting via Builder.

Synopsis

TextFmt

type TextFmt = Fmt Builder Source #

A Fmt specialized to Builder.

runTextFmt :: TextFmt Text a -> a Source #

Run a TextFmt to produce lazy Text.

printf :: TextFmt (IO ()) a -> a Source #

Run a TextFmt and print the result to stdout.

Combinators

cat1With :: Foldable f => ([Text] -> Text) -> Fmt1 Builder Text a -> Fmt1 Builder s (f a) Source #

Format each value in a foldable and join the results.

hsep :: Foldable f => Fmt1 Builder Text a -> Fmt1 Builder s (f a) Source #

Format each value with spaces in between.

vsep :: Foldable f => Fmt1 Builder Text a -> Fmt1 Builder s (f a) Source #

Format each value on its own line.

hang :: Foldable f => Int -> Fmt1 Builder Text a -> Fmt1 Builder s (f a) Source #

Format each value on its own line, indented by n spaces.

list1 :: Foldable f => Fmt1 Builder Text a -> Fmt1 Builder s (f a) Source #

Format in square brackets with comma separation.

Splitting

replace1 :: Text -> Fmt Builder a a -> Fmt Builder a b -> Fmt Builder a b Source #

Replace the first occurrence of a search term.

splitWith :: (Text -> (Text, Text)) -> (Text -> Text -> Fmt Builder a2 a1) -> Fmt Builder a1 b -> Fmt Builder a2 b Source #

Split the formatted output using a splitting function, then rejoin with a custom combinator.

Running Fmt1

run1 :: Fmt1 Builder Text a -> a -> Text Source #

Run a Fmt1 to strict Text.

Structured output

jsonList :: Foldable f => Fmt1 Builder Text a -> Fmt1 Builder s (f a) Source #

Format a foldable as a JSON-style list.

yamlList :: Foldable f => Fmt1 Builder Text a -> Fmt1 Builder s (f a) Source #

Format a foldable as a YAML-style list.

jsonMap :: Foldable f => Fmt1 Builder Text k -> Fmt1 Builder Text v -> Fmt1 Builder s (f (k, v)) Source #

Format key-value pairs as a JSON-style map.

yamlMap :: Foldable f => Fmt1 Builder Text k -> Fmt1 Builder Text v -> Fmt1 Builder s (f (k, v)) Source #

Format key-value pairs as a YAML-style map.