2023-10-25 11:06:35 +00:00
|
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
2023-10-24 20:08:10 +00:00
|
|
|
module Language.Yanais.Parser.IO (
|
2023-10-25 11:06:35 +00:00
|
|
|
parseFile
|
2023-10-24 20:08:10 +00:00
|
|
|
) where
|
|
|
|
|
|
|
|
import qualified Data.ByteString.Char8 as C
|
|
|
|
import qualified Language.Yanais.Parser as P
|
|
|
|
|
2023-10-25 11:06:35 +00:00
|
|
|
parseFile :: String -> P.Parser' e a -> IO (Either e a)
|
|
|
|
parseFile f p = do
|
|
|
|
contents <- C.readFile f
|
|
|
|
let pe = P.makeParseEnv contents
|
|
|
|
return (fmap (\(r, _) -> r) $ P.runParser pe p)
|