aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2014-07-20 23:41:42 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2015-02-18 12:50:20 +0000
commit7a649170bef70f33099000277f42362d4ab7ff50 (patch)
treed0f16a7cbf1a8ed5c3b91aabce706e426ee4af08 /src/Text/Pandoc
parent3480189e8e3edce51351629444e5ed0db2c21eef (diff)
downloadpandoc-7a649170bef70f33099000277f42362d4ab7ff50.tar.gz
Added generalize function which can be used to lift specialised parsers.
Monad m => Parsec s st a -> Parsec T s st m a
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Parsing.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 28ea2bd2f..ec15adf77 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -109,6 +109,7 @@ module Text.Pandoc.Parsing ( anyLine,
askF,
asksF,
token,
+ generalize,
-- * Re-exports from Text.Pandoc.Parsec
Stream,
runParser,
@@ -1264,3 +1265,6 @@ addWarning mbpos msg =
updateState $ \st -> st{
stateWarnings = (msg ++ maybe "" (\pos -> " " ++ show pos) mbpos) :
stateWarnings st }
+
+generalize :: (Monad m) => Parser s st a -> ParserT s st m a
+generalize m = mkPT (\ s -> (return $ (return . runIdentity) <$> runIdentity (runParsecT m s)))