Changed behavior of readJournalFiles to be identical to readJournalFile for singleton lists (#437)

This commit is contained in:
Johannes Gerer 2016-12-01 01:39:33 +01:00 committed by Simon Michael
parent eac2ff0ea7
commit 2e8e67aa09

View File

@ -36,6 +36,7 @@ module Hledger.Read (
) where
import Control.Applicative ((<|>))
import Control.Arrow (right)
import qualified Control.Exception as C
import Control.Monad.Except
import Data.List
@ -126,8 +127,11 @@ defaultJournalPath = do
--
readJournalFiles :: Maybe StorageFormat -> Maybe FilePath -> Bool -> [PrefixedFilePath] -> IO (Either String Journal)
readJournalFiles mformat mrulesfile assrt prefixedfiles = do
(either Left (Right . mconcat) . sequence)
(right mconcat1 . sequence)
<$> mapM (readJournalFile mformat mrulesfile assrt) prefixedfiles
where mconcat1 :: Monoid t => [t] -> t
mconcat1 [] = mempty
mconcat1 x = foldr1 mappend x
-- | @readJournalFile mformat mrulesfile assrt prefixedfile@
--