-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Parser for TOML files
--   
--   TOML is an obvious and minimal format for config files.
--   
--   This package provides a TOML parser, build with the Parsec library. It
--   exposes a JSON interface using the Aeson library.
@package htoml
@version 1.0.0.3

module Text.Toml.Types

-- | The TOML <a>Table</a> is a mapping (<a>HashMap</a>) of <a>Text</a>
--   keys to <a>Node</a> values.
type Table = HashMap Text Node

-- | Contruct an empty <a>Table</a>.
emptyTable :: Table

-- | An array of <a>Table</a>s, implemented using a <a>Vector</a>.
type VTArray = Vector Table

-- | A "value" array that may contain zero or more <a>Node</a>s,
--   implemented using a <a>Vector</a>.
type VArray = Vector Node

-- | A <a>Node</a> may contain any type of value that may be put in a
--   <a>VArray</a>.
data Node
VTable :: !Table -> Node
VTArray :: !VTArray -> Node
VString :: !Text -> Node
VInteger :: !Int64 -> Node
VFloat :: !Double -> Node
VBoolean :: !Bool -> Node
VDatetime :: !UTCTime -> Node
VArray :: !VArray -> Node

-- | To mark whether or not a <a>Table</a> has been explicitly defined.
--   See: <a>https://github.com/toml-lang/toml/issues/376</a>
data Explicitness
Explicit :: Explicitness
Implicit :: Explicitness

-- | Convenience function to get a boolean value.
isExplicit :: Explicitness -> Bool

-- | Inserts a table, <a>Table</a>, with the namespaced name, '[Text]',
--   (which may be part of a table array) into a <a>Table</a>. It may
--   result in an error in the <a>ParsecT</a> monad for redefinitions.
insert :: Explicitness -> ([Text], Node) -> Table -> Parsec Text (Set [Text]) Table
class ToJSON a
toJSON :: ToJSON a => a -> Value
toEncoding :: ToJSON a => a -> Encoding
toJSONList :: ToJSON a => [a] -> Value
toEncodingList :: ToJSON a => [a] -> Encoding
omitField :: ToJSON a => a -> Bool

-- | Type class for conversion to BurntSushi-style JSON.
--   
--   BurntSushi has made a language agnostic test suite available that this
--   library uses. This test suit expects that values are encoded as JSON
--   objects with a 'type' and a <tt>value</tt> member.
class ToBsJSON a
toBsJSON :: ToBsJSON a => a -> Value
instance GHC.Classes.Eq Text.Toml.Types.Explicitness
instance GHC.Classes.Eq Text.Toml.Types.Node
instance GHC.Internal.Show.Show Text.Toml.Types.Explicitness
instance GHC.Internal.Show.Show Text.Toml.Types.Node
instance Text.Toml.Types.ToBsJSON v => Text.Toml.Types.ToBsJSON (Data.HashMap.Internal.HashMap Data.Text.Internal.Text v)
instance Text.Toml.Types.ToBsJSON v => Text.Toml.Types.ToBsJSON (Data.Aeson.KeyMap.KeyMap v)
instance Text.Toml.Types.ToBsJSON Text.Toml.Types.Node
instance Text.Toml.Types.ToBsJSON a => Text.Toml.Types.ToBsJSON (Data.Vector.Vector a)
instance Data.Aeson.Types.ToJSON.ToJSON Text.Toml.Types.Node

module Text.Toml.Parser

-- | <ul>
--   <li>Toml value parsers</li>
--   </ul>
array :: Parser Node

-- | Our very own Parser type.
type Parser a = forall s. () => Parsec Text s a

-- | Attoparsec <tt>double</tt> parses scientific "e" notation; reimplement
--   according to Toml spec.
float :: Parser Node
integer :: Parser Node

-- | Parses a value.
value :: Parser Node
datetime :: Parser Node

-- | Convenience function for the test suite and GHCI.
parseOnly :: Parsec Text (Set [Text]) a -> Text -> Either ParseError a

-- | Parses a complete document formatted according to the TOML spec.
tomlDoc :: Parsec Text (Set [Text]) Table

-- | Parses the (rest of the) line including an EOF, whitespace and
--   comments.
skipBlanks :: Parser ()

-- | Parses a table of key-value pairs.
table :: Parser Table

-- | Parses a <a>Table</a> or <tt>TableArray</tt> with its header. The
--   resulting tuple has the header's value in the first position, and the
--   <tt>NTable</tt> or <tt>NTArray</tt> in the second.
namedSection :: Parser ([Text], Node)

-- | Parses a key-value assignment.
assignment :: Parser (Text, Node)

-- | Find dupes, if any.
maybeDupe :: Ord a => [a] -> Maybe a

-- | Parses an inline table of key-value pairs.
inlineTable :: Parser Node

-- | Results in <a>True</a> for whitespace chars, tab or space, according
--   to spec.
isSpc :: Char -> Bool

-- | Parses a table header.
tableHeader :: Parser [Text]

-- | Parses a table array header.
tableArrayHeader :: Parser [Text]

-- | Parses the value of any header (names separated by dots), into a list
--   of <a>Text</a>.
headerValue :: Parser [Text]
anyStr' :: Parser Text
boolean :: Parser Node
anyStr :: Parser Node

-- | Parses the elements of an array, while restricting them to a certain
--   type.
arrayOf :: Parser Node -> Parser Node
multiBasicStr :: Parser Text
basicStr :: Parser Text
multiLiteralStr :: Parser Text
literalStr :: Parser Text

-- | Parser for escape sequences.
escSeq :: Parser Char

-- | Parser for signs (a plus or a minus).
signed :: Num a => Parser a -> Parser a

-- | Parser for unicode hexadecimal values of representation length
--   <tt>n</tt>.
unicodeHex :: Int -> Parser Char

-- | Parse an EOL, as per TOML spec this is 0x0A a.k.a. 'n' or 0x0D a.k.a.
--   'r'.
eol :: Parser ()

module Text.Toml

-- | Parse a <a>Text</a> that results in <a>Either</a> a <a>String</a>
--   containing the error message, or an internal representation of the
--   document as a <a>Table</a>.
parseTomlDoc :: String -> Text -> Either ParseError Table
