yanais/haskell/nfker7h/lib/Language/Yanais/Parser/IO.hs

14 lines
370 B
Haskell
Raw Normal View History

2023-10-25 11:06:35 +00:00
{-# LANGUAGE ScopedTypeVariables #-}
module Language.Yanais.Parser.IO (
2023-10-25 11:06:35 +00:00
parseFile
) 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)