diff options
| author | Gregor Kleen <aethoago@141.li> | 2017-01-26 22:10:29 +0100 |
|---|---|---|
| committer | Gregor Kleen <aethoago@141.li> | 2017-01-26 22:10:29 +0100 |
| commit | 067c9c10e08bc48678687996945b35fa921229f4 (patch) | |
| tree | d3e78984cb65a285b9c6b2c6ea29938709088289 /lib/Postdelay/Utils.hs | |
| parent | 0557c61d62bbcb01afc2f2604fa631062e034cc2 (diff) | |
| download | postdelay-067c9c10e08bc48678687996945b35fa921229f4.tar postdelay-067c9c10e08bc48678687996945b35fa921229f4.tar.gz postdelay-067c9c10e08bc48678687996945b35fa921229f4.tar.bz2 postdelay-067c9c10e08bc48678687996945b35fa921229f4.tar.xz postdelay-067c9c10e08bc48678687996945b35fa921229f4.zip | |
Basic concepts
Diffstat (limited to 'lib/Postdelay/Utils.hs')
| -rw-r--r-- | lib/Postdelay/Utils.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Postdelay/Utils.hs b/lib/Postdelay/Utils.hs new file mode 100644 index 0000000..d716b4d --- /dev/null +++ b/lib/Postdelay/Utils.hs | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | {-# LANGUAGE FlexibleContexts #-} | ||
| 2 | |||
| 3 | module Postdelay.Utils | ||
| 4 | ( hoistParsecT | ||
| 5 | ) where | ||
| 6 | |||
| 7 | import Control.Monad.Error.Class | ||
| 8 | |||
| 9 | import Data.Functor | ||
| 10 | import Data.Either | ||
| 11 | |||
| 12 | import Data.Functor.Identity | ||
| 13 | import Text.Parsec.Prim | ||
| 14 | import Text.Parsec.Error | ||
| 15 | |||
| 16 | hoistParsecT :: (Monad m, Stream s Identity t, Stream s m t) => ParsecT s u Identity a -> ParsecT s u m a | ||
| 17 | hoistParsecT p = do | ||
| 18 | st <- getParserState | ||
| 19 | let res = runParser p' undefined "" undefined | ||
| 20 | p' = setParserState st >> ((,) <$> getState <*> p) | ||
| 21 | either (fail . show) (\(st', res) -> putState st' $> res) $ res | ||
