From b53ebcdf8e8e1f7098a0c93ead4b5bf99971c77f Mon Sep 17 00:00:00 2001 From: Jesse Rosenthal Date: Mon, 28 Nov 2016 17:13:46 -0500 Subject: Working on readers. --- src/Text/Pandoc/Class.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/Text/Pandoc/Class.hs') diff --git a/src/Text/Pandoc/Class.hs b/src/Text/Pandoc/Class.hs index 12e6f900b..5cef621dc 100644 --- a/src/Text/Pandoc/Class.hs +++ b/src/Text/Pandoc/Class.hs @@ -35,6 +35,7 @@ module Text.Pandoc.Class ( PandocMonad(..) , PureState(..) , PureEnv(..) , getPOSIXTime + , addWarningWithPos , PandocIO(..) , PandocPure(..) , PandocExecutionError(..) @@ -57,6 +58,7 @@ import qualified Text.Pandoc.Shared as IO ( fetchItem , warn , readDataFile) import Text.Pandoc.Compat.Time (UTCTime) +import Text.Pandoc.Parsing (ParserT, ParserState, SourcePos) import qualified Text.Pandoc.Compat.Time as IO (getCurrentTime) import Data.Time.Clock.POSIX ( utcTimeToPOSIXSeconds , posixSecondsToUTCTime @@ -109,6 +111,14 @@ class (Functor m, Applicative m, Monad m, MonadError PandocExecutionError m) => getPOSIXTime :: (PandocMonad m) => m POSIXTime getPOSIXTime = utcTimeToPOSIXSeconds <$> getCurrentTime +addWarningWithPos :: PandocMonad m + => Maybe SourcePos + -> String + -> ParserT [Char] ParserState m () +addWarningWithPos mbpos msg = + lift $ + warn $ + msg ++ maybe "" (\pos -> " " ++ show pos) mbpos -- We can add to this as we go data PandocExecutionError = PandocFileReadError FilePath -- cgit v1.2.3