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.Write.Beancount

Helpers for beancount output.

  • 6 values
valuetagsToBeancountMetadata :: [Tag] -> [BMetadata]
#

Make a list of tags ready to be rendered as Beancount metadata: Encode and lengthen names, encode values, and combine repeated tags into one. Metadatas will be sorted by (encoded) name and then value.

valueshowBeancountMetadata :: Maybe Int -> BMetadata -> Text
#

Render a Beancount metadata as a metadata line (without the indentation or newline). If a maximum name length is provided, space will be left after the colon so that successive metadata values will all start at the same column.

valueaccountNameToBeancount :: AccountName -> BeancountAccountName
#

Convert a hledger account name to a valid Beancount account name. It replaces spaces with dashes and other non-supported characters with CHEXBYTES; prepends the letter A to any part which doesn't begin with a letter or number; adds a second :A part if there is only one part; and capitalises each part. It also checks that the first part is one of the required english account names Assets, Liabilities, Equity, Income, or Expenses, and if not raises an informative error. Ref: https://beancount.github.io/docs/beancount_language_syntax.html#accounts

valuecommodityToBeancount :: CommoditySymbol -> BeancountCommoditySymbol
#

Convert a hledger commodity name to a valid Beancount commodity name. That is: 2-24 uppercase letters digits apostrophe period underscore / dash, starting with a letter, and ending with a letter or digit. Ref: https://beancount.github.io/docs/beancount_language_syntax.html#commodities-currencies So this: replaces common currency symbols with their ISO 4217 currency codes, capitalises all letters, replaces spaces with dashes and other invalid characters with CHEXBYTES, prepends a C if the first character is not a letter, appends a C if the last character is not a letter or digit, and disables hledger's enclosing double quotes.

Example5 expressions
commodityToBeancount """C"commodityToBeancount "$""USD"commodityToBeancount "Usd""USD"commodityToBeancount "\"a1\"""A1"commodityToBeancount "\"A 1!\"""A-1C21"

Tests

1 declaration