aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2014-07-20 23:41:42 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2015-03-22 18:57:36 +0000
commit8271fb574ebb0a6049ffe05959d416ac86637378 (patch)
treec4ba4d73e0837bc442cdcf96443d80a1bb1b7747 /src/Text
parentb983adf0d0cbc98d2da1e2751f46ae1f93352be6 (diff)
downloadpandoc-8271fb574ebb0a6049ffe05959d416ac86637378.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')
-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)))