HORIZON HASKELLDocslts/ghc-10.0.x8c2f8e82026-10-19Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8c2f8e8 · 2026-10-19

Modulehledger-lib-1.52.4GHC2021

Hledger.Utils.Text

Text formatting helpers, ported from String as needed. There may be better alternatives out there.

  • 1 type
  • 23 values

misc

9 declarations
valuetextUnbracket :: Text -> Text
#

Remove all matching pairs of square brackets and parentheses from the text.

valuequoteIfSpaced :: Text -> Text
#

Wrap a string in double quotes, and -prefix any embedded single quotes, if it contains whitespace and is not already single- or double-quoted.

valuestripquotes :: Text -> Text
#

Strip one matching pair of single or double quotes on the ends of a string.

single-line layout

2 declarations
valueformatText :: Bool -> Maybe Int -> Maybe Int -> Text -> Text
#

Clip and pad a string to a minimum & maximum width, andor leftright justify it. Works on multi-line strings too (but will rewrite non-unix line endings).

multi-line layout

6 declarations
valuetextConcatTopPadded :: [Text] -> Text
#

Join several multi-line strings as side-by-side rectangular strings of the same height, top-padded. Treats wide characters as double width.

Join several multi-line strings as side-by-side rectangular strings of the same height, bottom-padded. Treats wide characters as double width.

valuefitText :: Maybe Int -> Maybe Int -> Bool -> Bool -> Text -> Text
#

General-purpose wide-char-aware single-line text layout function. It can left- or right-pad a short string to a minimum width. It can left- or right-clip a long string to a maximum width, optionally inserting an ellipsis (the third argument). It clips and pads on the right when the fourth argument is true, otherwise on the left. It treats wide characters as double width.

wide-character-aware layout

5 declarations
valuetextTakeWidth :: Int -> Text -> Text
#

Double-width-character-aware string truncation. Take as many characters as possible from a string without exceeding the specified width. Eg textTakeWidth 3 "りんご" = "り".

Reading

1 declaration
valuereadDecimal :: Text -> Integer
#

Read a decimal number from a Text. Assumes the input consists only of digit characters.

tests

1 declaration