summaryrefslogtreecommitdiff
path: root/lib/Postdelay/Utils.hs
diff options
context:
space:
mode:
authorGregor Kleen <aethoago@141.li>2017-01-26 22:10:29 +0100
committerGregor Kleen <aethoago@141.li>2017-01-26 22:10:29 +0100
commit067c9c10e08bc48678687996945b35fa921229f4 (patch)
treed3e78984cb65a285b9c6b2c6ea29938709088289 /lib/Postdelay/Utils.hs
parent0557c61d62bbcb01afc2f2604fa631062e034cc2 (diff)
downloadpostdelay-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.hs21
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
3module Postdelay.Utils
4 ( hoistParsecT
5 ) where
6
7import Control.Monad.Error.Class
8
9import Data.Functor
10import Data.Either
11
12import Data.Functor.Identity
13import Text.Parsec.Prim
14import Text.Parsec.Error
15
16hoistParsecT :: (Monad m, Stream s Identity t, Stream s m t) => ParsecT s u Identity a -> ParsecT s u m a
17hoistParsecT 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