summaryrefslogtreecommitdiff
path: root/src/Hakyll/Parsec/Parsec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Hakyll/Parsec/Parsec.hs')
-rw-r--r--src/Hakyll/Parsec/Parsec.hs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/Hakyll/Parsec/Parsec.hs b/src/Hakyll/Parsec/Parsec.hs
new file mode 100644
index 0000000..cac653c
--- /dev/null
+++ b/src/Hakyll/Parsec/Parsec.hs
@@ -0,0 +1,20 @@
+module Hakyll.Parsec.Parsec
+ ( compileParsec
+ , compileParsec_
+ , evalParsec
+ ) where
+
+import Prolog
+import Hakyll
+import Text.Parsec
+import Text.Parsec.Error
+import Hakyll.Error
+
+-- evalParsec :: (MonadError [String] m) => Either ParseError a -> m a
+-- evalParsec = either (throwError . fmap messageString . errorMessages) pure
+
+compileParsec :: (MonadError [String] m, Stream s Identity t) => Parsec s u a -> u -> Item s -> m (Item a)
+compileParsec p u itm@(Item i _) = traverse (liftErr . runParser p u (show i)) itm
+
+compileParsec_ :: (MonadError [String] m, Stream s Identity t) => Parsec s () a -> Item s -> m (Item a)
+compileParsec_ p = compileParsec p ()