From 2d21ec0174c3a2282db335fe9c98440f2d17a438 Mon Sep 17 00:00:00 2001 From: Alex Chen Date: Wed, 6 Jun 2018 00:29:52 -0600 Subject: [PATCH] lib: weaken parser types --- hledger-lib/Hledger/Read/Common.hs | 4 ++-- hledger-lib/Hledger/Read/JournalReader.hs | 8 ++++---- hledger-lib/Hledger/Read/TimeclockReader.hs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hledger-lib/Hledger/Read/Common.hs b/hledger-lib/Hledger/Read/Common.hs index c646a485f..0a38a7909 100644 --- a/hledger-lib/Hledger/Read/Common.hs +++ b/hledger-lib/Hledger/Read/Common.hs @@ -217,12 +217,12 @@ generateAutomaticPostings j = j { jtxns = map modifier $ jtxns j } -- | Given a megaparsec ParsedJournal parser, input options, file -- path and file content: parse and post-process a Journal, or give an error. -parseAndFinaliseJournal :: ErroringJournalParser IO ParsedJournal -> InputOpts +parseAndFinaliseJournal :: JournalParser IO ParsedJournal -> InputOpts -> FilePath -> Text -> ExceptT String IO Journal parseAndFinaliseJournal parser iopts f txt = do t <- liftIO getClockTime y <- liftIO getCurrentYear - ep <- runParserT (evalStateT parser nulljournal {jparsedefaultyear=Just y}) f txt + ep <- liftIO $ runParserT (evalStateT parser nulljournal {jparsedefaultyear=Just y}) f txt case ep of Right pj -> let pj' = if auto_ iopts then generateAutomaticPostings pj else pj in diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index 438c746ca..decf20b4f 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -139,7 +139,7 @@ aliasesFromOpts = map (\a -> fromparse $ runParser accountaliasp ("--alias "++qu -- >>> rejp (journalp <* eof) "2015/1/1\n a 0\n" -- Right Journal with 1 transactions, 1 accounts -- -journalp :: MonadIO m => ErroringJournalParser m ParsedJournal +journalp :: MonadIO m => JournalParser m ParsedJournal journalp = do many addJournalItemP eof @@ -147,7 +147,7 @@ journalp = do -- | A side-effecting parser; parses any kind of journal item -- and updates the parse state accordingly. -addJournalItemP :: MonadIO m => ErroringJournalParser m () +addJournalItemP :: MonadIO m => JournalParser m () addJournalItemP = -- all journal line types can be distinguished by the first -- character, can use choice without backtracking @@ -166,7 +166,7 @@ addJournalItemP = -- | Parse any journal directive and update the parse state accordingly. -- Cf http://hledger.org/manual.html#directives, -- http://ledger-cli.org/3.0/doc/ledger3.html#Command-Directives -directivep :: MonadIO m => ErroringJournalParser m () +directivep :: MonadIO m => JournalParser m () directivep = (do optional $ char '!' choice [ @@ -186,7 +186,7 @@ directivep = (do ] ) "directive" -includedirectivep :: MonadIO m => ErroringJournalParser m () +includedirectivep :: MonadIO m => JournalParser m () includedirectivep = do string "include" lift (skipSome spacenonewline) diff --git a/hledger-lib/Hledger/Read/TimeclockReader.hs b/hledger-lib/Hledger/Read/TimeclockReader.hs index 2d9708afe..0971fe03b 100644 --- a/hledger-lib/Hledger/Read/TimeclockReader.hs +++ b/hledger-lib/Hledger/Read/TimeclockReader.hs @@ -83,7 +83,7 @@ reader = Reader parse :: InputOpts -> FilePath -> Text -> ExceptT String IO Journal parse = parseAndFinaliseJournal timeclockfilep -timeclockfilep :: MonadIO m => ErroringJournalParser m ParsedJournal +timeclockfilep :: MonadIO m => JournalParser m ParsedJournal timeclockfilep = do many timeclockitemp eof j@Journal{jparsetimeclockentries=es} <- get