From 067c9c10e08bc48678687996945b35fa921229f4 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 26 Jan 2017 22:10:29 +0100 Subject: Basic concepts --- lib/Postdelay/Utils.hs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/Postdelay/Utils.hs (limited to 'lib/Postdelay/Utils.hs') 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 @@ +{-# 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 -- cgit v1.2.3