{-# LANGUAGE DeriveAnyClass #-}
module Toml.Parser
( ParseException (..)
, parse
) where
import Control.DeepSeq (NFData)
import Data.Text (Text, pack)
import GHC.Generics (Generic)
import Toml.Parser.TOML (tomlP)
import Toml.Type (TOML)
import qualified Toml.Parser.Core as P (errorBundlePretty, parse)
newtype ParseException = ParseException Text
deriving (Show, Eq, Generic, NFData)
parse :: Text -> Either ParseException TOML
parse t = case P.parse tomlP "" t of
Left err -> Left $ ParseException $ pack $ P.errorBundlePretty err
Right toml -> Right toml