diff --git a/CHANGES.md b/CHANGES.md
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,11 +7,29 @@
            
 Breaking changes
 
-Misc. changes
+Fixes
 
+Improvements
+
 -->
 Internal/api/developer-ish changes in the hledger-lib (and hledger) packages.
 For user-visible changes, see the hledger package changelog.
+
+# 1.32.2 2023-12-31
+
+Breaking changes
+
+- In Hledger.Data.Amount, noPrice is renamed to noCost.
+
+- AmountDisplayOpts has a new displayCommodity flag, controlling commodity symbol display.
+
+Fixes
+
+- Hledger.Utils.Debug.traceOrLog was logging when it should trace and vice versa.
+
+Improvements
+
+- Allow megaparsec 9.6
 
 # 1.32.1 2023-12-07
 
diff --git a/Hledger/Data/Amount.hs b/Hledger/Data/Amount.hs
--- a/Hledger/Data/Amount.hs
+++ b/Hledger/Data/Amount.hs
@@ -80,7 +80,7 @@
   -- ** rendering
   AmountDisplayOpts(..),
   noColour,
-  noPrice,
+  noCost,
   oneLine,
   csvDisplay,
   showAmountB,
@@ -174,7 +174,7 @@
 import Data.List.NonEmpty (NonEmpty(..), nonEmpty)
 import qualified Data.Map.Strict as M
 import qualified Data.Set as S
-import Data.Maybe (fromMaybe, isNothing, isJust)
+import Data.Maybe (fromMaybe, isNothing)
 import Data.Semigroup (Semigroup(..))
 import qualified Data.Text as T
 import qualified Data.Text.Lazy.Builder as TB
@@ -219,18 +219,20 @@
 -- | Options for the display of Amount and MixedAmount.
 -- (ee also Types.AmountStyle.
 data AmountDisplayOpts = AmountDisplayOpts
-  { displayPrice         :: Bool       -- ^ Whether to display the Price of an Amount.
-  , displayZeroCommodity :: Bool       -- ^ If the Amount rounds to 0, whether to display its commodity string.
-  , displayThousandsSep  :: Bool       -- ^ Whether to display digit group marks (eg thousands separators)
-  , displayAddDecimalMark  :: Bool     -- ^ Whether to add a trailing decimal mark when there are no decimal digits 
-                                       --   and there are digit group marks, to disambiguate
-  , displayColour        :: Bool       -- ^ Whether to colourise negative Amounts.
-  , displayOneLine       :: Bool       -- ^ Whether to display on one line.
-  , displayMinWidth      :: Maybe Int  -- ^ Minimum width to pad to
-  , displayMaxWidth      :: Maybe Int  -- ^ Maximum width to clip to
-  -- | Display amounts in this order (without the commodity symbol) and display
-  -- a 0 in case a corresponding commodity does not exist
-  , displayOrder         :: Maybe [CommoditySymbol]
+  { displayCommodity        :: Bool       -- ^ Whether to display commodity symbols.
+  , displayZeroCommodity    :: Bool       -- ^ Whether to display commodity symbols for zero Amounts.
+  , displayCommodityOrder   :: Maybe [CommoditySymbol]
+                                          -- ^ For a MixedAmount, an optional order in which to display the commodities.
+                                          --   Also, causes 0s to be generated for any commodities which are not present
+                                          --   (important for tabular reports).
+  , displayDigitGroups      :: Bool       -- ^ Whether to display digit group marks (eg thousands separators)
+  , displayForceDecimalMark :: Bool       -- ^ Whether to add a trailing decimal mark when there are no decimal digits 
+                                          --   and there are digit group marks, to disambiguate
+  , displayOneLine          :: Bool       -- ^ Whether to display on one line.
+  , displayMinWidth         :: Maybe Int  -- ^ Minimum width to pad to
+  , displayMaxWidth         :: Maybe Int  -- ^ Maximum width to clip to
+  , displayCost             :: Bool       -- ^ Whether to display Amounts' costs.
+  , displayColour           :: Bool       -- ^ Whether to ansi-colourise negative Amounts.
   } deriving (Show)
 
 -- | By default, display Amount and MixedAmount using @noColour@ amount display options.
@@ -238,28 +240,30 @@
 
 -- | Display amounts without colour, and with various other defaults.
 noColour :: AmountDisplayOpts
-noColour = AmountDisplayOpts { displayPrice         = True
-                             , displayColour        = False
-                             , displayZeroCommodity = False
-                             , displayThousandsSep  = True
-                             , displayAddDecimalMark = False
-                             , displayOneLine       = False
-                             , displayMinWidth      = Just 0
-                             , displayMaxWidth      = Nothing
-                             , displayOrder         = Nothing
-                             }
+noColour = AmountDisplayOpts {
+    displayCommodity        = True
+  , displayZeroCommodity    = False
+  , displayCommodityOrder   = Nothing
+  , displayDigitGroups      = True
+  , displayForceDecimalMark   = False
+  , displayOneLine          = False
+  , displayMinWidth         = Just 0
+  , displayMaxWidth         = Nothing
+  , displayCost             = True
+  , displayColour           = False
+  }
 
 -- | Display Amount and MixedAmount with no prices.
-noPrice :: AmountDisplayOpts
-noPrice = def{displayPrice=False}
+noCost :: AmountDisplayOpts
+noCost = def{displayCost=False}
 
 -- | Display Amount and MixedAmount on one line with no prices.
 oneLine :: AmountDisplayOpts
-oneLine = def{displayOneLine=True, displayPrice=False}
+oneLine = def{displayOneLine=True, displayCost=False}
 
 -- | Display Amount and MixedAmount in a form suitable for CSV output.
 csvDisplay :: AmountDisplayOpts
-csvDisplay = oneLine{displayThousandsSep=False}
+csvDisplay = oneLine{displayDigitGroups=False}
 
 -------------------------------------------------------------------------------
 -- Amount arithmetic
@@ -649,24 +653,21 @@
 showAmountB :: AmountDisplayOpts -> Amount -> WideBuilder
 showAmountB _ Amount{acommodity="AUTO"} = mempty
 showAmountB
-  AmountDisplayOpts{displayPrice, displayColour, displayZeroCommodity, 
-    displayThousandsSep, displayAddDecimalMark, displayOrder}
+  AmountDisplayOpts{displayCommodity, displayZeroCommodity, displayDigitGroups
+                   ,displayForceDecimalMark, displayCost, displayColour}
   a@Amount{astyle=style} =
     color $ case ascommodityside style of
-      L -> showC (wbFromText comm) space <> quantity' <> price
-      R -> quantity' <> showC space (wbFromText comm) <> price
+      L -> (if displayCommodity then wbFromText comm <> space else mempty) <> quantity' <> price
+      R -> quantity' <> (if displayCommodity then space <> wbFromText comm else mempty) <> price
   where
     color = if displayColour && isNegativeAmount a then colorB Dull Red else id
-    quantity = showAmountQuantity displayAddDecimalMark $
-      if displayThousandsSep then a else a{astyle=(astyle a){asdigitgroups=Nothing}}
+    quantity = showAmountQuantity displayForceDecimalMark $
+      if displayDigitGroups then a else a{astyle=(astyle a){asdigitgroups=Nothing}}
     (quantity', comm)
       | amountLooksZero a && not displayZeroCommodity = (WideBuilder (TB.singleton '0') 1, "")
       | otherwise = (quantity, quoteCommoditySymbolIfNeeded $ acommodity a)
     space = if not (T.null comm) && ascommodityspaced style then WideBuilder (TB.singleton ' ') 1 else mempty
-    -- concatenate these texts,
-    -- or return the empty text if there's a commodity display order. XXX why ?
-    showC l r = if isJust displayOrder then mempty else l <> r
-    price = if displayPrice then showAmountPrice a else mempty
+    price = if displayCost then showAmountPrice a else mempty
 
 -- | Colour version. For a negative amount, adds ANSI codes to change the colour,
 -- currently to hard-coded red.
@@ -677,9 +678,9 @@
 
 -- | Get the string representation of an amount, without any \@ price.
 --
--- > showAmountWithoutPrice = wbUnpack . showAmountB noPrice
+-- > showAmountWithoutPrice = wbUnpack . showAmountB noCost
 showAmountWithoutPrice :: Amount -> String
-showAmountWithoutPrice = wbUnpack . showAmountB noPrice
+showAmountWithoutPrice = wbUnpack . showAmountB noCost
 
 -- | Like showAmount, but show a zero amount's commodity if it has one.
 --
@@ -1040,7 +1041,7 @@
 --
 -- > showMixedAmountOneLine = wbUnpack . showMixedAmountB oneLine
 showMixedAmountOneLine :: MixedAmount -> String
-showMixedAmountOneLine = wbUnpack . showMixedAmountB oneLine{displayPrice=True}
+showMixedAmountOneLine = wbUnpack . showMixedAmountB oneLine{displayCost=True}
 
 -- | Like showMixedAmount, but zero amounts are shown with their
 -- commodity if they have one.
@@ -1052,9 +1053,9 @@
 -- | Get the string representation of a mixed amount, without showing any transaction prices.
 -- With a True argument, adds ANSI codes to show negative amounts in red.
 --
--- > showMixedAmountWithoutPrice c = wbUnpack . showMixedAmountB noPrice{displayColour=c}
+-- > showMixedAmountWithoutPrice c = wbUnpack . showMixedAmountB noCost{displayColour=c}
 showMixedAmountWithoutPrice :: Bool -> MixedAmount -> String
-showMixedAmountWithoutPrice c = wbUnpack . showMixedAmountB noPrice{displayColour=c}
+showMixedAmountWithoutPrice c = wbUnpack . showMixedAmountB noCost{displayColour=c}
 
 -- | Get the one-line string representation of a mixed amount, but without
 -- any \@ prices.
@@ -1107,7 +1108,7 @@
     map (adBuilder . pad) elided
   where
     astrs = amtDisplayList (wbWidth sep) (showAmountB opts) . orderedAmounts opts $
-              if displayPrice opts then ma else mixedAmountStripPrices ma
+              if displayCost opts then ma else mixedAmountStripPrices ma
     sep   = WideBuilder (TB.singleton '\n') 0
     width = maximum $ map (wbWidth . adBuilder) elided
 
@@ -1133,7 +1134,7 @@
   where
     width  = maybe 0 adTotal $ lastMay elided
     astrs  = amtDisplayList (wbWidth sep) (showAmountB opts) . orderedAmounts opts $
-               if displayPrice opts then ma else mixedAmountStripPrices ma
+               if displayCost opts then ma else mixedAmountStripPrices ma
     sep    = WideBuilder (TB.fromString ", ") 2
     n      = length astrs
 
@@ -1159,7 +1160,7 @@
 -- optionally preserving multiple zeros in different commodities,
 -- optionally sorting them according to a commodity display order.
 orderedAmounts :: AmountDisplayOpts -> MixedAmount -> [Amount]
-orderedAmounts AmountDisplayOpts{displayZeroCommodity=preservezeros, displayOrder=mcommodityorder} =
+orderedAmounts AmountDisplayOpts{displayZeroCommodity=preservezeros, displayCommodityOrder=mcommodityorder} =
   if preservezeros then amountsPreservingZeros else amounts
   <&> maybe id (mapM findfirst) mcommodityorder  -- maybe sort them (somehow..)
   where
diff --git a/Hledger/Data/Posting.hs b/Hledger/Data/Posting.hs
--- a/Hledger/Data/Posting.hs
+++ b/Hledger/Data/Posting.hs
@@ -293,7 +293,7 @@
       | elideamount = [mempty]
       | otherwise   = showMixedAmountLinesB displayopts $ pamount p
         where displayopts = noColour{
-          displayZeroCommodity=True, displayAddDecimalMark=True, displayOneLine=onelineamounts
+          displayZeroCommodity=True, displayForceDecimalMark=True, displayOneLine=onelineamounts
           }
     thisamtwidth = maximumBound 0 $ map wbWidth shownAmounts
 
@@ -361,7 +361,7 @@
       | elideamount = [mempty]
       | otherwise   = showMixedAmountLinesB displayopts a'
         where
-          displayopts = noColour{ displayZeroCommodity=True, displayAddDecimalMark=True }
+          displayopts = noColour{ displayZeroCommodity=True, displayForceDecimalMark=True }
           a' = mapMixedAmount amountToBeancount $ pamount p
     thisamtwidth = maximumBound 0 $ map wbWidth shownAmounts
 
@@ -539,11 +539,11 @@
 postingToCost :: ConversionOp -> Posting -> Maybe Posting
 postingToCost NoConversionOp p = Just p
 postingToCost ToCost         p
-    -- If this is a conversion posting with a matched transaction price posting, ignore it
-    | "_conversion-matched" `elem` map fst (ptags p) && noCost = Nothing
-    | otherwise = Just $ postingTransformAmount mixedAmountCost p
+  -- If this is a conversion posting with a matched transaction price posting, ignore it
+  | "_conversion-matched" `elem` map fst (ptags p) && nocosts = Nothing
+  | otherwise = Just $ postingTransformAmount mixedAmountCost p
   where
-    noCost = (not . any (isJust . aprice) . amountsRaw) $ pamount p
+    nocosts = (not . any (isJust . aprice) . amountsRaw) $ pamount p
 
 -- | Generate inferred equity postings from a 'Posting' using transaction prices.
 -- Make sure not to generate equity postings when there are already matched
diff --git a/Hledger/Data/RawOptions.hs b/Hledger/Data/RawOptions.hs
--- a/Hledger/Data/RawOptions.hs
+++ b/Hledger/Data/RawOptions.hs
@@ -9,6 +9,8 @@
 
 module Hledger.Data.RawOptions (
   RawOpts,
+  mkRawOpts,
+  overRawOpts,
   setopt,
   setboolopt,
   unsetboolopt,
@@ -24,8 +26,7 @@
   posintopt,
   maybeintopt,
   maybeposintopt,
-  maybecharopt,
-  overRawOpts
+  maybecharopt
 )
 where
 
@@ -42,6 +43,10 @@
 
 instance Default RawOpts where def = RawOpts []
 
+mkRawOpts :: [(String,String)] -> RawOpts
+mkRawOpts = RawOpts
+
+overRawOpts :: ([(String,String)] -> [(String,String)]) -> RawOpts -> RawOpts
 overRawOpts f = RawOpts . f . unRawOpts
 
 setopt :: String -> String -> RawOpts -> RawOpts
diff --git a/Hledger/Data/Valuation.hs b/Hledger/Data/Valuation.hs
--- a/Hledger/Data/Valuation.hs
+++ b/Hledger/Data/Valuation.hs
@@ -364,6 +364,12 @@
       case concatMap extend paths of
         [] -> Nothing 
         _ | pathlength > maxpathlength -> 
+          -- XXX This is unusual:
+          -- 1. A warning, not an error, which we usually avoid
+          -- 2. Not a debug message (when triggered, we always print it)
+          -- 3. Printed either to stdout or (eg in hledger-ui) to the debug log file.
+          -- This is the only place we use traceOrLog like this.
+          -- Also before 1.32.2, traceOrLog was doing the opposite of what it should [#2134].
           traceOrLog ("gave up searching for a price chain at length "++show maxpathlength++", please report a bug")
           Nothing
           where 
diff --git a/Hledger/Read/RulesReader.hs b/Hledger/Read/RulesReader.hs
--- a/Hledger/Read/RulesReader.hs
+++ b/Hledger/Read/RulesReader.hs
@@ -69,7 +69,7 @@
 import qualified Data.ByteString.Lazy as BL
 import Data.Foldable (asum, toList)
 import Text.Megaparsec hiding (match, parse)
-import Text.Megaparsec.Char (char, newline, string)
+import Text.Megaparsec.Char (char, newline, string, digitChar)
 import Text.Megaparsec.Custom (parseErrorAt)
 import Text.Printf (printf)
 
@@ -297,6 +297,9 @@
 -- containing csv field references to be interpolated.
 type FieldTemplate    = Text
 
+-- | A reference to a regular expression match group. Eg \1.
+type MatchGroupReference = Text
+
 -- | A strptime date parsing pattern, as supported by Data.Time.Format.
 type DateFormat       = Text
 
@@ -773,23 +776,31 @@
         matcherPrefix (FieldMatcher prefix _ _) = prefix
 
 -- | Render a field assignment's template, possibly interpolating referenced
--- CSV field values. Outer whitespace is removed from interpolated values.
+-- CSV field values or match groups. Outer whitespace is removed from interpolated values.
 renderTemplate ::  CsvRules -> CsvRecord -> HledgerFieldName -> FieldTemplate -> Text
-renderTemplate rules record f t = maybe t mconcat $ parseMaybe
-    (many $ takeWhile1P Nothing isNotEscapeChar
-        <|> replaceRegexGroupReference rules record f <$> matchp
-        <|> replaceCsvFieldReference rules record <$> referencep)
+renderTemplate rules record f t =
+  maybe t mconcat $ parseMaybe
+    (many
+      (   literaltextp
+      <|> (matchrefp <&> replaceRegexGroupReference rules record f)
+      <|> (fieldrefp <&> replaceCsvFieldReference   rules record)
+      )
+    )
     t
   where
-    -- XXX: can we return a parsed Int here?
-    matchp = liftA2 T.cons (char '\\') (takeWhile1P (Just "matchref") isDigit) :: Parsec HledgerParseErrorData Text Text
-    referencep = liftA2 T.cons (char '%') (takeWhile1P (Just "reference") isFieldNameChar) :: Parsec HledgerParseErrorData Text Text
+    literaltextp :: SimpleTextParser Text
+    literaltextp = some (nonBackslashOrPercent <|> nonRefBackslash <|> nonRefPercent) <&> T.pack
+      where
+        nonBackslashOrPercent = noneOf ['\\', '%'] <?> "character other than backslash or percent"
+        nonRefBackslash = try (char '\\' <* notFollowedBy digitChar) <?> "backslash that does not begin a match group reference"
+        nonRefPercent   = try (char '%'  <* notFollowedBy (satisfy isFieldNameChar)) <?> "percent that does not begin a field reference"
+    matchrefp    = liftA2 T.cons (char '\\') (takeWhile1P (Just "matchref")  isDigit)
+    fieldrefp    = liftA2 T.cons (char '%')  (takeWhile1P (Just "reference") isFieldNameChar)
     isFieldNameChar c = isAlphaNum c || c == '_' || c == '-'
-    isNotEscapeChar c = c /='%' && c /= '\\'
 
 -- | Replace something that looks like a Regex match group reference with the
 -- resulting match group value after applying the Regex.
-replaceRegexGroupReference :: CsvRules -> CsvRecord -> HledgerFieldName -> FieldTemplate -> Text
+replaceRegexGroupReference :: CsvRules -> CsvRecord -> HledgerFieldName -> MatchGroupReference -> Text
 replaceRegexGroupReference rules record f s = case T.uncons s of
     Just ('\\', group) -> fromMaybe "" $ regexMatchValue rules record f group
     _                  -> s
diff --git a/Hledger/Read/TimedotReader.hs b/Hledger/Read/TimedotReader.hs
--- a/Hledger/Read/TimedotReader.hs
+++ b/Hledger/Read/TimedotReader.hs
@@ -209,8 +209,8 @@
 -- (or empty string for none).
 durationsp :: TextParser m [(Hours,TagValue)]
 durationsp =
-      (dotquantityp     <&> \h -> [(h,"")])
-  <|> (numericquantityp <&> \h -> [(h,"")])
+      (try numericquantityp <&> \h -> [(h,"")])  -- try needed because numbers can begin with .
+  <|> (dotquantityp     <&> \h -> [(h,"")])
   <|> letterquantitiesp
   <|> pure [(0,"")]
 
diff --git a/Hledger/Reports/BudgetReport.hs b/Hledger/Reports/BudgetReport.hs
--- a/Hledger/Reports/BudgetReport.hs
+++ b/Hledger/Reports/BudgetReport.hs
@@ -324,10 +324,10 @@
         padcells = maybetranspose . fmap (fmap (uncurry paddisplaycell) . zip widths)   . maybetranspose
         padtr    = maybetranspose . fmap (fmap (uncurry paddisplaycell) . zip trwidths) . maybetranspose
 
-        -- commodities are shown with the amounts without `layout_ == LayoutBare`
+        -- with --layout=bare, begin with a commodity column
         prependcs cs
-          | layout_ /= LayoutBare = id
-          | otherwise = zipWith (:) cs
+          | layout_ == LayoutBare = zipWith (:) cs
+          | otherwise             = id
 
     rowToBudgetCells (PeriodicReportRow _ as rowtot rowavg) = as
         ++ [rowtot | row_total_ && not (null as)]
@@ -337,9 +337,9 @@
     rowfuncs :: [CommoditySymbol] -> (BudgetShowMixed, BudgetPercBudget)
     rowfuncs cs = case layout_ of
       LayoutWide width ->
-           ( pure . showMixedAmountB oneLine{displayColour=color_, displayMaxWidth=width}
+           ( pure . showMixedAmountB oneLine{displayMaxWidth=width, displayColour=color_}
            , \a -> pure . percentage a)
-      _ -> ( showMixedAmountLinesB noPrice{displayOrder=Just cs, displayMinWidth=Nothing, displayColour=color_}
+      _ -> ( showMixedAmountLinesB noCost{displayCommodity=layout_/=LayoutBare, displayCommodityOrder=Just cs, displayMinWidth=Nothing, displayColour=color_}
            , \a b -> fmap (percentage' a b) cs)
 
     showrow :: [BudgetCell] -> [(WideBuilder, BudgetDisplayRow)]
@@ -476,11 +476,11 @@
       | otherwise =
             joinNames . zipWith (:) cs  -- add symbols and names
           . transpose                   -- each row becomes a list of Text quantities
-          . fmap (fmap wbToText . showMixedAmountLinesB oneLine{displayOrder=Just cs, displayMinWidth=Nothing}
-                 .fromMaybe nullmixedamt)
+          . fmap (fmap wbToText . showMixedAmountLinesB dopts . fromMaybe nullmixedamt)
           $ vals
       where
         cs = S.toList . foldl' S.union mempty . fmap maCommodities $ catMaybes vals
+        dopts = oneLine{displayCommodity=layout_ /= LayoutBare, displayCommodityOrder=Just cs, displayMinWidth=Nothing}
         vals = flattentuples as
             ++ concat [[rowtot, budgettot] | row_total_]
             ++ concat [[rowavg, budgetavg] | average_]
diff --git a/Hledger/Utils/Debug.hs b/Hledger/Utils/Debug.hs
--- a/Hledger/Utils/Debug.hs
+++ b/Hledger/Utils/Debug.hs
@@ -329,27 +329,27 @@
   then return ()
   else traceLogIO (labelledPretty False label a)
 
--- Trace or log a string depending on shouldLog,
+-- | Trace or log a string depending on shouldLog,
 -- before returning the second argument.
 traceOrLog :: String -> a -> a
-traceOrLog = if shouldLog then trace else traceLog
+traceOrLog = if shouldLog then traceLog else trace
 
--- Trace or log a string depending on shouldLog,
+-- | Trace or log a string depending on shouldLog,
 -- when global debug level is at or above the specified level,
 -- before returning the second argument.
 traceOrLogAt :: Int -> String -> a -> a
 traceOrLogAt = if shouldLog then traceLogAt else traceAt
 
--- Pretty-trace or log depending on shouldLog, when global debug level
+-- | Pretty-trace or log depending on shouldLog, when global debug level
 -- is at or above the specified level.
 ptraceOrLogAt :: Show a => Int -> String -> a -> a
 ptraceOrLogAt = if shouldLog then ptraceLogAt else ptraceAt
 
--- Like ptraceOrLogAt, but convenient in IO.
+-- | Like ptraceOrLogAt, but convenient in IO.
 ptraceOrLogAtIO :: (MonadIO m, Show a) => Int -> String -> a -> m ()
 ptraceOrLogAtIO = if shouldLog then ptraceLogAtIO else ptraceAtIO
 
--- Trace or log, with a show function, depending on shouldLog.
+-- | Trace or log, with a show function, depending on shouldLog.
 traceOrLogAtWith :: Int -> (a -> String) -> a -> a
 traceOrLogAtWith = if shouldLog then traceLogAtWith else traceAtWith
 
diff --git a/Hledger/Utils/Parse.hs b/Hledger/Utils/Parse.hs
--- a/Hledger/Utils/Parse.hs
+++ b/Hledger/Utils/Parse.hs
@@ -39,8 +39,8 @@
   skipNonNewlineSpaces',
 
   -- ** Trace the state of hledger parsers
-  traceOrLogParse,
   dbgparse,
+  traceOrLogParse,
 
   -- * re-exports
   HledgerParseErrors,
@@ -72,7 +72,17 @@
 -- | A parser of text that runs in some monad.
 type TextParser m a = ParsecT HledgerParseErrorData Text m a
 
+-- class (Stream s, MonadPlus m) => MonadParsec e s m 
+-- dbgparse :: (MonadPlus m, MonadParsec e String m) => Int -> String -> m ()
+
 -- | Trace to stderr or log to debug log the provided label (if non-null)
+-- and current parser state (position and next input),
+-- if the global debug level is at or above the specified level.
+-- Uses unsafePerformIO.
+dbgparse :: Int -> String -> TextParser m ()
+dbgparse level msg = when (level <= debugLevel) $ traceOrLogParse msg
+
+-- | Trace to stderr or log to debug log the provided label (if non-null)
 -- and current parser state (position and next input).
 -- See also: Hledger.Utils.Debug, megaparsec's dbg.
 -- Uses unsafePerformIO.
@@ -87,16 +97,6 @@
   traceOrLog s' $ return ()
   where
     peeklength = 30
-
--- class (Stream s, MonadPlus m) => MonadParsec e s m 
--- dbgparse :: (MonadPlus m, MonadParsec e String m) => Int -> String -> m ()
-
--- | Trace to stderr or log to debug log the provided label (if non-null)
--- and current parser state (position and next input),
--- if the global debug level is at or above the specified level.
--- Uses unsafePerformIO.
-dbgparse :: Int -> String -> TextParser m ()
-dbgparse level msg = when (level <= debugLevel) $ traceOrLogParse msg
 
 -- | Render a pair of source positions in human-readable form, only displaying the range of lines.
 sourcePosPairPretty :: (SourcePos, SourcePos) -> String
diff --git a/hledger-lib.cabal b/hledger-lib.cabal
--- a/hledger-lib.cabal
+++ b/hledger-lib.cabal
@@ -5,7 +5,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           hledger-lib
-version:        1.32.1
+version:        1.32.2
 synopsis:       A library providing the core functionality of hledger
 description:    This library contains hledger's core functionality.
                 It is used by most hledger* packages so that they support the same
@@ -131,7 +131,7 @@
     , file-embed >=0.0.10
     , filepath
     , hashtables >=1.2.3.1
-    , megaparsec >=7.0.0 && <9.6
+    , megaparsec >=7.0.0 && <9.7
     , microlens >=0.4
     , microlens-th >=0.4
     , mtl >=2.2.1
@@ -190,7 +190,7 @@
     , file-embed >=0.0.10
     , filepath
     , hashtables >=1.2.3.1
-    , megaparsec >=7.0.0 && <9.6
+    , megaparsec >=7.0.0 && <9.7
     , microlens >=0.4
     , microlens-th >=0.4
     , mtl >=2.2.1
@@ -251,7 +251,7 @@
     , filepath
     , hashtables >=1.2.3.1
     , hledger-lib
-    , megaparsec >=7.0.0 && <9.6
+    , megaparsec >=7.0.0 && <9.7
     , microlens >=0.4
     , microlens-th >=0.4
     , mtl >=2.2.1
