diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2014-07-20 23:41:42 +0100 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2015-03-22 18:57:36 +0000 |
commit | 8271fb574ebb0a6049ffe05959d416ac86637378 (patch) | |
tree | c4ba4d73e0837bc442cdcf96443d80a1bb1b7747 /src/Text | |
parent | b983adf0d0cbc98d2da1e2751f46ae1f93352be6 (diff) | |
download | pandoc-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.hs | 4 |
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))) |