From 591abefe9e489e26497f087fa7fd91facd34b7bc Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 24 Sep 2015 14:23:52 -1000 Subject: [PATCH] clarify modifiedaccountnamep --- hledger-lib/Hledger/Read/JournalReader.hs | 18 ++++++++++-------- hledger-lib/Hledger/Read/TimelogReader.hs | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index c88b3128e..76c1b1663 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -31,7 +31,7 @@ module Hledger.Read.JournalReader ( datetimep, codep, accountnamep, - modifiedaccountname, + modifiedaccountnamep, postingp, amountp, amountp', @@ -577,7 +577,7 @@ postingp = do many1 spacenonewline status <- statusp many spacenonewline - account <- modifiedaccountname + account <- modifiedaccountnamep let (ptype, account') = (accountNamePostingType account, unbracket account) amount <- spaceandamountormissing massertion <- partialbalanceassertion @@ -657,13 +657,15 @@ test_postingp = do #endif -- | Parse an account name, then apply any parent account prefix and/or account aliases currently in effect. -modifiedaccountname :: Stream [Char] m Char => ParsecT [Char] JournalContext m AccountName -modifiedaccountname = do - a <- accountnamep - prefix <- getParentAccount - let prefixed = prefix `joinAccountNames` a +modifiedaccountnamep :: Stream [Char] m Char => ParsecT [Char] JournalContext m AccountName +modifiedaccountnamep = do + parent <- getParentAccount aliases <- getAccountAliases - return $ accountNameApplyAliases aliases prefixed + a <- accountnamep + return $ + accountNameApplyAliases aliases $ + joinAccountNames parent + a -- | Parse an account name. Account names start with a non-space, may -- have single spaces inside them, and are terminated by two or more diff --git a/hledger-lib/Hledger/Read/TimelogReader.hs b/hledger-lib/Hledger/Read/TimelogReader.hs index cdf25b415..e41312ef6 100644 --- a/hledger-lib/Hledger/Read/TimelogReader.hs +++ b/hledger-lib/Hledger/Read/TimelogReader.hs @@ -61,7 +61,7 @@ import Hledger.Data -- XXX too much reuse ? import Hledger.Read.JournalReader ( directive, marketpricedirective, defaultyeardirective, emptyorcommentlinep, datetimep, - parseJournalWith, modifiedaccountname, genericSourcePos + parseJournalWith, modifiedaccountnamep, genericSourcePos ) import Hledger.Utils @@ -107,7 +107,7 @@ timelogentry = do code <- oneOf "bhioO" many1 spacenonewline datetime <- datetimep - account <- fromMaybe "" <$> optionMaybe (many1 spacenonewline >> modifiedaccountname) + account <- fromMaybe "" <$> optionMaybe (many1 spacenonewline >> modifiedaccountnamep) description <- fromMaybe "" <$> optionMaybe (many1 spacenonewline >> restofline) return $ TimeLogEntry sourcepos (read [code]) datetime account description