module Text.Toml ( parseTomlDoc
                 , parseErrorPretty
                 , Table
                 , Node (..)
                 ) where

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

-- | Parse a 'Text' that results in 'Either' a 'TomlError'
-- containing the error message, or an internal representation
-- of the document as a 'Table'.
parseTomlDoc :: FilePath -- ^ For error generation
             -> Text -- ^ TOML source
             -> Either TomlError Table
parseTomlDoc :: FilePath -> Text -> Either TomlError Table
parseTomlDoc FilePath
_ = (State (Set [Text]) (Either TomlError Table)
 -> Set [Text] -> Either TomlError Table)
-> Set [Text]
-> State (Set [Text]) (Either TomlError Table)
-> Either TomlError Table
forall a b c. (a -> b -> c) -> b -> a -> c
flip State (Set [Text]) (Either TomlError Table)
-> Set [Text] -> Either TomlError Table
forall s a. State s a -> s -> a
evalState Set [Text]
forall a. Monoid a => a
mempty (State (Set [Text]) (Either TomlError Table)
 -> Either TomlError Table)
-> (Text -> State (Set [Text]) (Either TomlError Table))
-> Text
-> Either TomlError Table
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT Void Text (StateT (Set [Text]) Identity) Table
-> FilePath -> Text -> State (Set [Text]) (Either TomlError Table)
forall (m :: * -> *) e s a.
Monad m =>
ParsecT e s m a
-> FilePath -> s -> m (Either (ParseErrorBundle s e) a)
runParserT ParsecT Void Text (StateT (Set [Text]) Identity) Table
forall (m :: * -> *). TomlM m => Parser m Table
tomlDoc FilePath
"noneSrc"