diff --git a/hledger-lib/Hledger/Data/Types.hs b/hledger-lib/Hledger/Data/Types.hs index c8ed06ebb..7f80a2c1f 100644 --- a/hledger-lib/Hledger/Data/Types.hs +++ b/hledger-lib/Hledger/Data/Types.hs @@ -167,9 +167,9 @@ data Journal = Journal { final_comment_lines :: String, -- ^ any trailing comments from the journal file jContext :: JournalContext, -- ^ the context (parse state) at the end of parsing files :: [(FilePath, String)], -- ^ 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. + -- any included journal files. The main file is + -- first followed by any included files in the + -- order encountered (XXX reversed, cf journalAddFile). filereadtime :: ClockTime -- ^ when this journal was last read from its file(s) } deriving (Eq, Typeable) diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index 595a36d97..1818df982 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -79,7 +79,7 @@ parse _ = -- trace ("running "++format++" reader") . -- | Flatten a list of JournalUpdate's into a single equivalent one. combineJournalUpdates :: [JournalUpdate] -> JournalUpdate -combineJournalUpdates us = liftM (foldl' (flip (.)) id) $ sequence us +combineJournalUpdates us = liftM (foldl' (.) id) $ sequence us -- | Given a JournalUpdate-generating parsec parser, file path and data string, -- parse and post-process a Journal so that it's ready to use, or give an error. @@ -191,6 +191,7 @@ includedirective = do journalAddFile :: (FilePath,String) -> Journal -> Journal journalAddFile f j@Journal{files=fs} = j{files=fs++[f]} + -- XXX currently called in reverse order of includes, I can't see why accountdirective :: GenParser Char JournalContext JournalUpdate accountdirective = do diff --git a/hledger/Hledger/Cli/Stats.hs b/hledger/Hledger/Cli/Stats.hs index a499f8b41..a14b6a218 100644 --- a/hledger/Hledger/Cli/Stats.hs +++ b/hledger/Hledger/Cli/Stats.hs @@ -42,7 +42,8 @@ showLedgerStats l today span = -- w2 = maximum $ map (length . show . snd) stats stats = [ ("Main journal file", path) -- ++ " (from " ++ source ++ ")") - ,("Included journal files", unlines $ drop 1 $ journalFilePaths j) + ,("Included journal files", unlines $ reverse $ -- cf journalAddFile + drop 1 $ journalFilePaths j) ,("Transactions span", printf "%s to %s (%d days)" (start span) (end span) days) ,("Last transaction", maybe "none" show lastdate ++ showelapsed lastelapsed) ,("Transactions", printf "%d (%0.1f per day)" tnum txnrate)