diff options
| author | Chris Wells <chris@mathematicaster.org> | 2025-01-11 10:28:34 -0600 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2025-01-11 10:28:34 -0600 |
| commit | 1a3ecbb58d85f70be0625777f9deb9a58907d2e2 (patch) | |
| tree | 88ab89ecbe8946b06e09ab0e594878f8572e72de /src/Hakyll/Parsec | |
| parent | 42a2d42eecf551dd1990c97c1ae2586cd46674be (diff) | |
| download | main-1a3ecbb58d85f70be0625777f9deb9a58907d2e2.tar main-1a3ecbb58d85f70be0625777f9deb9a58907d2e2.tar.gz main-1a3ecbb58d85f70be0625777f9deb9a58907d2e2.tar.bz2 main-1a3ecbb58d85f70be0625777f9deb9a58907d2e2.tar.lz main-1a3ecbb58d85f70be0625777f9deb9a58907d2e2.tar.xz main-1a3ecbb58d85f70be0625777f9deb9a58907d2e2.tar.zst main-1a3ecbb58d85f70be0625777f9deb9a58907d2e2.zip | |
More basic modules for errors and parsers
Diffstat (limited to 'src/Hakyll/Parsec')
| -rw-r--r-- | src/Hakyll/Parsec/Parsec.hs | 20 |
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 () |
