diff --git a/hledger-lib/Hledger/Data/Journal.hs b/hledger-lib/Hledger/Data/Journal.hs index 895106a12..ed36259dc 100644 --- a/hledger-lib/Hledger/Data/Journal.hs +++ b/hledger-lib/Hledger/Data/Journal.hs @@ -63,7 +63,7 @@ import Data.List import Data.Maybe import Data.Monoid import Data.Ord --- import Data.Text (Text) +import Data.Text (Text) import qualified Data.Text as T import Safe (headMay, headDef) import Data.Time.Calendar @@ -185,7 +185,7 @@ journalFilePath = fst . mainfile journalFilePaths :: Journal -> [FilePath] journalFilePaths = map fst . jfiles -mainfile :: Journal -> (FilePath, String) +mainfile :: Journal -> (FilePath, Text) mainfile = headDef ("", "") . jfiles addTransaction :: Transaction -> Journal -> Journal @@ -455,7 +455,7 @@ journalApplyAliases aliases j@Journal{jtxns=ts} = -- use. Reverse parsed data to normal order, canonicalise amount -- formats, check/ensure that transactions are balanced, and maybe -- check balance assertions. -journalFinalise :: ClockTime -> FilePath -> String -> Bool -> ParsedJournal -> Either String Journal +journalFinalise :: ClockTime -> FilePath -> Text -> Bool -> ParsedJournal -> Either String Journal journalFinalise t path txt assrt j@Journal{jfiles=fs} = do (journalBalanceTransactions $ journalApplyCommodityStyles $ diff --git a/hledger-lib/Hledger/Data/Types.hs b/hledger-lib/Hledger/Data/Types.hs index 6f6a66111..3f3a341ef 100644 --- a/hledger-lib/Hledger/Data/Types.hs +++ b/hledger-lib/Hledger/Data/Types.hs @@ -251,7 +251,7 @@ data Journal = Journal { ,jperiodictxns :: [PeriodicTransaction] ,jtxns :: [Transaction] ,jfinalcommentlines :: String -- ^ any final trailing comments in the (main) journal file - ,jfiles :: [(FilePath, String)] -- ^ the file path and raw text of the main and + ,jfiles :: [(FilePath, Text)] -- ^ the file path and raw text of the main and -- any included journal files. The main file is first, -- followed by any included files in the order encountered. ,jlastreadtime :: ClockTime -- ^ when this journal was last read from its file(s) diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index 0817b19f4..f0c705b63 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -27,7 +27,7 @@ import Data.Functor.Identity import Data.List.Compat import Data.List.Split (wordsBy) import Data.Maybe --- import Data.Text (Text) +import Data.Text (Text) import qualified Data.Text as T import Data.Time.Calendar import Data.Time.LocalTime @@ -76,7 +76,7 @@ parseAndFinaliseJournal parser assrt f s = do y <- liftIO getCurrentYear ep <- runParserT parser nulljournal{jparsedefaultyear=Just y} f s case ep of - Right pj -> case journalFinalise t f s assrt pj of + Right pj -> case journalFinalise t f (T.pack s) assrt pj of Right j -> return j Left e -> throwError e Left e -> throwError $ show e @@ -130,7 +130,7 @@ incrementTransactionCount = do modifyState (\j -> j{jparsetransactioncount=jparsetransactioncount j + 1}) getTransactionCount -journalAddFile :: (FilePath,String) -> Journal -> Journal +journalAddFile :: (FilePath,Text) -> Journal -> Journal journalAddFile f j@Journal{jfiles=fs} = j{jfiles=fs++[f]} -- append, unlike the other fields, even though we do a final reverse, -- to compensate for additional reversal due to including/monoid-concatting diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index e8040e7da..c7839b0ae 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -203,7 +203,7 @@ includedirectivep = do (throwError . ((show parentpos ++ " in included file " ++ show filename ++ ":\n") ++) . show) - (return . journalAddFile (filepath,txt)) + (return . journalAddFile (filepath, T.pack txt)) ej1 case ej of Left e -> throwError e