From f9fc39fe8eaa7b77b7daf90fe808b6fbc3b3273b Mon Sep 17 00:00:00 2001 From: Saku Laesvuori Date: Sat, 19 Jul 2025 15:28:35 +0300 Subject: [PATCH] =?UTF-8?q?Lis=C3=A4=C3=A4=20yksinkertaiset=20funktiot=20T?= =?UTF-8?q?ITO-tiedostojen=20lukemiseen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Data/TITO.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Data/TITO.hs b/src/Data/TITO.hs index 01aac20..df376b5 100644 --- a/src/Data/TITO.hs +++ b/src/Data/TITO.hs @@ -1,2 +1,17 @@ module Data.TITO where +import Control.Exception + +import qualified Data.ByteString as BS +import qualified Text.Megaparsec as P + +import Data.TITO.Parser +import Data.TITO.Types + +readTITO :: BS.ByteString -> Either ParseErrors TITO +readTITO = P.parse tito "" + +readTITOFile :: FilePath -> IO TITO +readTITOFile fp = + BS.readFile fp >>= + either (throwIO . ErrorCall . P.errorBundlePretty) pure . P.parse tito fp