blob: d716b4d69d1e57a41a22fd22bb1c6aeca6b886a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
{-# LANGUAGE FlexibleContexts #-}
module Postdelay.Utils
( hoistParsecT
) where
import Control.Monad.Error.Class
import Data.Functor
import Data.Either
import Data.Functor.Identity
import Text.Parsec.Prim
import Text.Parsec.Error
hoistParsecT :: (Monad m, Stream s Identity t, Stream s m t) => ParsecT s u Identity a -> ParsecT s u m a
hoistParsecT p = do
st <- getParserState
let res = runParser p' undefined "" undefined
p' = setParserState st >> ((,) <$> getState <*> p)
either (fail . show) (\(st', res) -> putState st' $> res) $ res
|