diff options
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 | ||