From 852ba7b10000077c6d77eda50bf76ea1019f0368 Mon Sep 17 00:00:00 2001 From: Stephen Morgan Date: Thu, 10 Mar 2022 12:13:28 +1100 Subject: [PATCH] fix: bin: Get hledger-print-location working. --- bin/hledger-print-location.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bin/hledger-print-location.hs b/bin/hledger-print-location.hs index 1d4ff3034..e5b083963 100755 --- a/bin/hledger-print-location.hs +++ b/bin/hledger-print-location.hs @@ -19,8 +19,7 @@ $ hledger print-location -f examples/sample.journal desc:eat {-# LANGUAGE QuasiQuotes #-} import Data.String.QQ (s) -import Data.Text (pack) -import Text.Printf +import qualified Data.Text as T import Hledger.Cli ------------------------------------------------------------------------------ @@ -44,9 +43,8 @@ main = do addLocationTag :: Transaction -> Transaction addLocationTag t = t{tcomment = tcomment t `commentAddTagNextLine` loctag} where - loctag = ("location", pack $ showGenericSourcePosLine $ tsourcepos t) + loctag = ("location", T.pack . showSourcePosPair $ tsourcepos t) --- Like showGenericSourcePos in Hledger.Data.Transaction, but show just the starting line number. -showGenericSourcePosLine :: GenericSourcePos -> String -showGenericSourcePosLine (GenericSourcePos f line _) = printf "%s:%d" f line -showGenericSourcePosLine (JournalSourcePos f (startline, _)) = printf "%s:%d" f startline +-- Like showSourcePosPair in Hledger.Data.Transaction, but show just the starting line number. +showSourcePosPairLine :: (SourcePos, SourcePos) -> String +showSourcePosPairLine (SourcePos f line _, _) = f ++ ":" ++ show line