module Text.Toml where

import           Control.Composition
import           Control.Monad.State (evalState)
import           Data.Text           (Text)
import           Text.Megaparsec
import           Text.Toml.Parser

-- | Parse a 'Text' that results in 'Either' a 'String'
-- containing the error message, or an internal representation
-- of the document as a 'Table'.
parseTomlDoc :: String -> Text -> Either TomlError Table
parseTomlDoc = flip evalState mempty .* runParserT tomlDoc