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


-- | TOML parser using generated lexers and parsers with careful attention
--   to the TOML 1.1.0 semantics for defining tables.
@package toml-parser
@version 2.0.2.0


-- | This type helps to build up computations that can validate a TOML
--   value and compute some application-specific representation.
--   
--   It supports warning messages which can be used to deprecate old
--   configuration options and to detect unused table keys.
--   
--   It supports tracking multiple error messages when you have more than
--   one decoding option and all of them have failed.
--   
--   Use <a>prettyMatchMessage</a> for an easy way to make human readable
--   strings from matcher outputs.
module Toml.Schema.Matcher

-- | Computations that result in a <a>Result</a> and which track a list of
--   nested contexts to assist in generating warnings and error messages.
--   
--   Use <a>withScope</a> to run a <a>Matcher</a> in a new, nested scope.
data Matcher l a

-- | Computation outcome with error and warning messages. Multiple error
--   messages can occur when multiple alternatives all fail. Resolving any
--   one of the error messages could allow the computation to succeed.
data Result e a

-- | error messages
Failure :: [e] -> Result e a

-- | warning messages and result
Success :: [e] -> a -> Result e a

-- | A message emitted while matching a TOML value. The message is paired
--   with the path to the value that was in focus when the message was
--   generated. These message get used for both warnings and errors.
--   
--   For a convenient way to render these to a string, see
--   <a>prettyMatchMessage</a>.
data MatchMessage a
MatchMessage :: Maybe a -> [Scope] -> String -> MatchMessage a
[matchAnn] :: MatchMessage a -> Maybe a

-- | path to message location
[matchPath] :: MatchMessage a -> [Scope]

-- | error and warning message body
[matchMessage] :: MatchMessage a -> String

-- | Run a <a>Matcher</a> with an empty scope.
runMatcher :: Matcher l a -> Result (MatchMessage l) a

-- | Run a <a>Matcher</a> with a locally extended scope.
withScope :: Scope -> Matcher l a -> Matcher l a

-- | Get the current list of scopes.
getScope :: Matcher a [Scope]

-- | Emit a warning without an annotation.
warn :: String -> Matcher a ()

-- | Emit a warning mentioning the given annotation.
warnAt :: l -> String -> Matcher l ()

-- | Terminate the match with an error mentioning the given annotation.
failAt :: l -> String -> Matcher l a

-- | Run <a>Matcher</a> and ignore warnings.
runMatcherIgnoreWarn :: Matcher l a -> Either [MatchMessage l] a

-- | Run <a>Matcher</a> and treat warnings as errors.
runMatcherFatalWarn :: Matcher l a -> Either [MatchMessage l] a

-- | Scopes for TOML message.
data Scope

-- | zero-based array index
ScopeIndex :: Int -> Scope

-- | key in a table
ScopeKey :: Text -> Scope

-- | Update the scope with the message corresponding to a table key
inKey :: Text -> Matcher l a -> Matcher l a

-- | Update the scope with the message corresponding to an array index
inIndex :: Int -> Matcher l a -> Matcher l a
instance GHC.Internal.Base.Alternative (Toml.Schema.Matcher.Matcher a)
instance GHC.Internal.Base.Applicative (Toml.Schema.Matcher.Matcher a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Toml.Schema.Matcher.MatchMessage a)
instance (GHC.Classes.Eq e, GHC.Classes.Eq a) => GHC.Classes.Eq (Toml.Schema.Matcher.Result e a)
instance GHC.Classes.Eq Toml.Schema.Matcher.Scope
instance GHC.Internal.Data.Foldable.Foldable Toml.Schema.Matcher.MatchMessage
instance GHC.Internal.Base.Functor Toml.Schema.Matcher.MatchMessage
instance GHC.Internal.Base.Functor (Toml.Schema.Matcher.Matcher a)
instance GHC.Internal.Control.Monad.Fail.MonadFail (Toml.Schema.Matcher.Matcher a)
instance GHC.Internal.Base.Monad (Toml.Schema.Matcher.Matcher a)
instance GHC.Internal.Base.MonadPlus (Toml.Schema.Matcher.Matcher a)
instance GHC.Internal.Base.Monoid (Toml.Schema.Matcher.DList a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Toml.Schema.Matcher.MatchMessage a)
instance (GHC.Classes.Ord e, GHC.Classes.Ord a) => GHC.Classes.Ord (Toml.Schema.Matcher.Result e a)
instance GHC.Classes.Ord Toml.Schema.Matcher.Scope
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Toml.Schema.Matcher.MatchMessage a)
instance (GHC.Internal.Read.Read e, GHC.Internal.Read.Read a) => GHC.Internal.Read.Read (Toml.Schema.Matcher.Result e a)
instance GHC.Internal.Read.Read Toml.Schema.Matcher.Scope
instance GHC.Internal.Base.Semigroup (Toml.Schema.Matcher.DList a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Toml.Schema.Matcher.MatchMessage a)
instance (GHC.Internal.Show.Show e, GHC.Internal.Show.Show a) => GHC.Internal.Show.Show (Toml.Schema.Matcher.Result e a)
instance GHC.Internal.Show.Show Toml.Schema.Matcher.Scope
instance GHC.Internal.Data.Traversable.Traversable Toml.Schema.Matcher.MatchMessage


-- | This module provides the type for the semantics of a TOML file. All
--   dotted keys are resolved in this representation. Each table is a Map
--   with a single level of keys.
--   
--   Values are parameterized over an annotation type to allow values to be
--   attributed to a file location. When values are constructed
--   programmatically, there might not be any interesting annotations. In
--   this case a trivial <tt>()</tt> unit annotation can be used. The
--   <a>Value</a> type-synonym and related pattern synonyms can make using
--   this case more convenient.
module Toml.Semantics.Types

-- | A <a>Value'</a> with trivial annotations
type Value = Value' ()

-- | A <a>Table'</a> with trivial annotations
type Table = Table' ()

-- | Semantic TOML value with all table assignments resolved.
data Value' a
Integer' :: a -> Integer -> Value' a
Double' :: a -> Double -> Value' a
List' :: a -> [Value' a] -> Value' a
Table' :: a -> Table' a -> Value' a
Bool' :: a -> Bool -> Value' a
Text' :: a -> Text -> Value' a
TimeOfDay' :: a -> TimeOfDay -> Value' a
ZonedTime' :: a -> ZonedTime -> Value' a
LocalTime' :: a -> LocalTime -> Value' a
Day' :: a -> Day -> Value' a
pattern Integer :: Integer -> Value
pattern Double :: Double -> Value
pattern Text :: Text -> Value
pattern Bool :: Bool -> Value
pattern ZonedTime :: ZonedTime -> Value
pattern Day :: Day -> Value
pattern LocalTime :: LocalTime -> Value
pattern TimeOfDay :: TimeOfDay -> Value
pattern List :: [Value] -> Value
pattern Table :: Table -> Value

-- | A table with annotated keys and values.
newtype Table' a
MkTable :: Map Text (a, Value' a) -> Table' a

-- | Replaces annotations with a unit.
forgetValueAnns :: Value' a -> Value

-- | Replaces annotations with a unit.
forgetTableAnns :: Table' a -> Table

-- | Extract the top-level annotation from a value.
valueAnn :: Value' a -> a

-- | String representation of the kind of value using TOML vocabulary
valueType :: Value' l -> String
instance GHC.Classes.Eq a => GHC.Classes.Eq (Toml.Semantics.Types.Table' a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Toml.Semantics.Types.Value' a)
instance GHC.Internal.Data.Foldable.Foldable Toml.Semantics.Types.Table'
instance GHC.Internal.Data.Foldable.Foldable Toml.Semantics.Types.Value'
instance GHC.Internal.Base.Functor Toml.Semantics.Types.Table'
instance GHC.Internal.Base.Functor Toml.Semantics.Types.Value'
instance (() GHC.Types.~ a) => GHC.Internal.Data.String.IsString (Toml.Semantics.Types.Value' a)
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Toml.Semantics.Types.Table' a)
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Toml.Semantics.Types.Value' a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Toml.Semantics.Types.Table' a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Toml.Semantics.Types.Value' a)
instance GHC.Internal.Data.Traversable.Traversable Toml.Semantics.Types.Table'
instance GHC.Internal.Data.Traversable.Traversable Toml.Semantics.Types.Value'


-- | This module provides the <a>Position</a> type for tracking locations
--   in files while doing lexing and parsing for providing more useful
--   error messages.
--   
--   This module assumes 8 column wide tab stops.
module Toml.Syntax.Position

-- | A value annotated with its text file position
data Located a
Located :: {-# UNPACK #-} !Position -> !a -> Located a

-- | position
[locPosition] :: Located a -> {-# UNPACK #-} !Position

-- | thing at position
[locThing] :: Located a -> !a

-- | A position in a text file
data Position
Position :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Position

-- | code-point index (zero-based)
[posIndex] :: Position -> {-# UNPACK #-} !Int

-- | line index (one-based)
[posLine] :: Position -> {-# UNPACK #-} !Int

-- | column index (one-based)
[posColumn] :: Position -> {-# UNPACK #-} !Int

-- | The initial <a>Position</a> for the start of a file
startPos :: Position

-- | Adjust a file position given a single character handling newlines and
--   tabs. All other characters are considered to fill exactly one column.
move :: Char -> Position -> Position
instance GHC.Classes.Eq Toml.Syntax.Position.Position
instance GHC.Internal.Data.Foldable.Foldable Toml.Syntax.Position.Located
instance GHC.Internal.Base.Functor Toml.Syntax.Position.Located
instance GHC.Classes.Ord Toml.Syntax.Position.Position
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Toml.Syntax.Position.Located a)
instance GHC.Internal.Read.Read Toml.Syntax.Position.Position
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Toml.Syntax.Position.Located a)
instance GHC.Internal.Show.Show Toml.Syntax.Position.Position
instance GHC.Internal.Data.Traversable.Traversable Toml.Syntax.Position.Located


-- | This module provides the datatype for the lexical syntax of TOML
--   files. These tokens are generated by <a>Toml.Syntax.Lexer</a> and
--   consumed in <a>Toml.Syntax.Parser</a>.
module Toml.Syntax.Token

-- | Lexical token
data Token

-- | <pre>
--   true
--   </pre>
TokTrue :: Token

-- | <pre>
--   false
--   </pre>
TokFalse :: Token

-- | <pre>
--   ','
--   </pre>
TokComma :: Token

-- | <pre>
--   '='
--   </pre>
TokEquals :: Token

-- | <pre>
--   end-of-line
--   </pre>
TokNewline :: Token

-- | <pre>
--   <a>.</a>
--   </pre>
TokPeriod :: Token

-- | <pre>
--   '['
--   </pre>
TokSquareO :: Token

-- | <pre>
--   ']'
--   </pre>
TokSquareC :: Token

-- | <pre>
--   '[['
--   </pre>
Tok2SquareO :: Token

-- | <pre>
--   ']]'
--   </pre>
Tok2SquareC :: Token

-- | <pre>
--   '{'
--   </pre>
TokCurlyO :: Token

-- | <pre>
--   '}'
--   </pre>
TokCurlyC :: Token

-- | bare key
TokBareKey :: Text -> Token

-- | string literal
TokString :: Text -> Token

-- | multiline string literal
TokMlString :: Text -> Token

-- | integer literal
TokInteger :: !Integer -> Token

-- | floating-point literal
TokFloat :: !Double -> Token

-- | date-time with timezone offset
TokOffsetDateTime :: !ZonedTime -> Token

-- | local date-time
TokLocalDateTime :: !LocalTime -> Token

-- | local date
TokLocalDate :: !Day -> Token

-- | local time
TokLocalTime :: !TimeOfDay -> Token

-- | <pre>
--   end-of-input
--   </pre>
TokEOF :: Token

-- | Construct a <a>TokInteger</a> from a binary integer literal lexeme.
mkBinInteger :: String -> Token

-- | Construct a <a>TokInteger</a> from a decimal integer literal lexeme.
mkDecInteger :: String -> Token

-- | Construct a <a>TokInteger</a> from a octal integer literal lexeme.
mkOctInteger :: String -> Token

-- | Construct a <a>TokInteger</a> from a hexadecimal integer literal
--   lexeme.
mkHexInteger :: String -> Token

-- | Construct a <a>TokFloat</a> from a floating-point literal lexeme.
mkFloat :: String -> Token

-- | Format strings for local date lexemes.
localDatePatterns :: [String]

-- | Format strings for local time lexemes.
localTimePatterns :: [String]

-- | Format strings for local datetime lexemes.
localDateTimePatterns :: [String]

-- | Format strings for offset datetime lexemes.
offsetDateTimePatterns :: [String]
instance GHC.Internal.Read.Read Toml.Syntax.Token.Token
instance GHC.Internal.Show.Show Toml.Syntax.Token.Token


-- | This module parses a TOML file into a lazy sequence of tokens. The
--   lexer is aware of nested brackets and equals signs in order to handle
--   TOML's context-sensitive lexing requirements. This context enables the
--   lexer to distinguish between bare keys and various values like:
--   floating-point literals, integer literals, and date literals.
--   
--   This module uses actions and lexical hooks defined in
--   <a>LexerUtils</a>.
module Toml.Syntax.Lexer

-- | Representation of the current lexer state.
data Context

-- | top-level where <tt>[[</tt> and <tt>]]</tt> have special meaning
TopContext :: Context

-- | inline table - lex key names
TableContext :: Context

-- | value lexer - lex number literals
ValueContext :: Context

-- | multiline basic string: position of opening delimiter and list of
--   fragments
MlBstrContext :: Position -> [Text] -> Context

-- | basic string: position of opening delimiter and list of fragments
BstrContext :: Position -> [Text] -> Context

-- | multiline literal string: position of opening delimiter and list of
--   fragments
MlLstrContext :: Position -> [Text] -> Context

-- | literal string: position of opening delimiter and list of fragments
LstrContext :: Position -> [Text] -> Context

-- | Get the next token from a located string or a located error message.
scanToken :: Context -> Located Text -> Either (Located String) (Located Token, Located Text)

-- | Lex a single token in a value context. This is mostly useful for
--   testing.
lexValue :: Text -> Either String Token

-- | Lexical token
data Token

-- | <pre>
--   true
--   </pre>
TokTrue :: Token

-- | <pre>
--   false
--   </pre>
TokFalse :: Token

-- | <pre>
--   ','
--   </pre>
TokComma :: Token

-- | <pre>
--   '='
--   </pre>
TokEquals :: Token

-- | <pre>
--   end-of-line
--   </pre>
TokNewline :: Token

-- | <pre>
--   <a>.</a>
--   </pre>
TokPeriod :: Token

-- | <pre>
--   '['
--   </pre>
TokSquareO :: Token

-- | <pre>
--   ']'
--   </pre>
TokSquareC :: Token

-- | <pre>
--   '[['
--   </pre>
Tok2SquareO :: Token

-- | <pre>
--   ']]'
--   </pre>
Tok2SquareC :: Token

-- | <pre>
--   '{'
--   </pre>
TokCurlyO :: Token

-- | <pre>
--   '}'
--   </pre>
TokCurlyC :: Token

-- | bare key
TokBareKey :: Text -> Token

-- | string literal
TokString :: Text -> Token

-- | multiline string literal
TokMlString :: Text -> Token

-- | integer literal
TokInteger :: !Integer -> Token

-- | floating-point literal
TokFloat :: !Double -> Token

-- | date-time with timezone offset
TokOffsetDateTime :: !ZonedTime -> Token

-- | local date-time
TokLocalDateTime :: !LocalTime -> Token

-- | local date
TokLocalDate :: !Day -> Token

-- | local time
TokLocalTime :: !TimeOfDay -> Token

-- | <pre>
--   end-of-input
--   </pre>
TokEOF :: Token


-- | This module provides a raw representation of TOML files as a list of
--   table definitions and key-value assignments.
--   
--   These values use the raw dotted keys and have no detection for
--   overlapping assignments.
--   
--   Further processing will happen in the <a>Semantics</a> module.
module Toml.Syntax.Types

-- | Non-empty sequence of dotted simple keys
type Key a = NonEmpty (a, Text)

-- | Headers and assignments corresponding to lines of a TOML file
data Expr a

-- | key value assignment: <tt>key = value</tt>
KeyValExpr :: Key a -> Val a -> Expr a

-- | table: <tt>[key]</tt>
TableExpr :: Key a -> Expr a

-- | array of tables: <tt>[[key]]</tt>
ArrayTableExpr :: Key a -> Expr a

-- | Unvalidated TOML values. Table are represented as a list of
--   assignments rather than as resolved maps.
data Val a
ValInteger :: a -> Integer -> Val a
ValFloat :: a -> Double -> Val a
ValArray :: a -> [Val a] -> Val a
ValTable :: a -> [(Key a, Val a)] -> Val a
ValBool :: a -> Bool -> Val a
ValString :: a -> Text -> Val a
ValTimeOfDay :: a -> TimeOfDay -> Val a
ValZonedTime :: a -> ZonedTime -> Val a
ValLocalTime :: a -> LocalTime -> Val a
ValDay :: a -> Day -> Val a

-- | Kinds of table headers
data SectionKind

-- | <ul>
--   <li><i>table</i></li>
--   </ul>
TableKind :: SectionKind

-- | <ul>
--   <li><i>[array of tables</i> ]</li>
--   </ul>
ArrayTableKind :: SectionKind
instance GHC.Classes.Eq Toml.Syntax.Types.SectionKind
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Toml.Syntax.Types.Expr a)
instance GHC.Internal.Read.Read Toml.Syntax.Types.SectionKind
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Toml.Syntax.Types.Val a)
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Toml.Syntax.Types.Expr a)
instance GHC.Internal.Show.Show Toml.Syntax.Types.SectionKind
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Toml.Syntax.Types.Val a)


-- | This module can help build a key ordering projection given an existing
--   TOML file. This could be useful for applying a transformation to a
--   TOML file before pretty-printing it back in something very close to
--   the original order.
--   
--   When using the computed order, table keys will be remembered in the
--   order they appeared in the source file. Any key additional keys added
--   to the tables will be ordered alphabetically after all the known keys.
--   
--   <pre>
--   demo =
--    do txt &lt;- <a>readFile</a> "demo.toml"
--       let Right exprs = <a>parseRawToml</a> txt
--           to          = <a>extractTableOrder</a> exprs
--           Right toml  = <a>semantics</a> exprs
--           projection  = <a>projectKey</a> to
--       <a>print</a> (<a>prettyTomlOrdered</a> projection toml)
--   </pre>
module Toml.Semantics.Ordered

-- | Summary of the order of the keys in a TOML document.
data TableOrder

-- | Extract a <a>TableOrder</a> from the output of <a>parseRawToml</a> to
--   be later used with <a>projectKey</a>.
extractTableOrder :: [Expr a] -> TableOrder

-- | Generate a projection function for use with <a>prettyTomlOrdered</a>
projectKey :: TableOrder -> [Text] -> Text -> ProjectedKey

-- | Opaque type used by <a>projectKey</a>
data ProjectedKey

-- | Render a white-space nested representation of the key ordering
--   extracted by <a>extractTableOrder</a>. This is provided for debugging
--   and understandability.
debugTableOrder :: TableOrder -> String
instance GHC.Classes.Eq Toml.Semantics.Ordered.ProjectedKey
instance GHC.Classes.Ord Toml.Semantics.Ordered.ProjectedKey


-- | This module extracts a nested Map representation of a TOML file. It
--   detects invalid key assignments and resolves dotted key assignments.
module Toml.Semantics

-- | A <a>Value'</a> with trivial annotations
type Value = Value' ()

-- | Semantic TOML value with all table assignments resolved.
data Value' a
Integer' :: a -> Integer -> Value' a
Double' :: a -> Double -> Value' a
List' :: a -> [Value' a] -> Value' a
Table' :: a -> Table' a -> Value' a
Bool' :: a -> Bool -> Value' a
Text' :: a -> Text -> Value' a
TimeOfDay' :: a -> TimeOfDay -> Value' a
ZonedTime' :: a -> ZonedTime -> Value' a
LocalTime' :: a -> LocalTime -> Value' a
Day' :: a -> Day -> Value' a
pattern Bool :: Bool -> Value
pattern Day :: Day -> Value
pattern Double :: Double -> Value
pattern Integer :: Integer -> Value
pattern List :: [Value] -> Value
pattern LocalTime :: LocalTime -> Value
pattern Table :: Table -> Value
pattern Text :: Text -> Value
pattern TimeOfDay :: TimeOfDay -> Value
pattern ZonedTime :: ZonedTime -> Value

-- | A <a>Table'</a> with trivial annotations
type Table = Table' ()

-- | A table with annotated keys and values.
newtype Table' a
MkTable :: Map Text (a, Value' a) -> Table' a

-- | Extracts a semantic value from a sequence of raw TOML expressions, or
--   reports a semantic error if one occurs.
semantics :: [Expr a] -> Either (SemanticError a) (Table' a)

-- | This type represents errors generated when resolving keys in a TOML
--   document.
data SemanticError a
SemanticError :: a -> Text -> SemanticErrorKind -> SemanticError a

-- | Annotation associated with offending key
[errorAnn] :: SemanticError a -> a
[errorKey] :: SemanticError a -> Text
[errorKind] :: SemanticError a -> SemanticErrorKind

-- | Enumeration of the kinds of conflicts a key can generate.
data SemanticErrorKind

-- | Attempted to assign to a key that was already assigned
AlreadyAssigned :: SemanticErrorKind

-- | Attempted to open a table already closed
ClosedTable :: SemanticErrorKind

-- | Attempted to open a tables as an array of tables that was implicitly
--   defined to be a table
ImplicitlyTable :: SemanticErrorKind

-- | Replaces annotations with a unit.
forgetTableAnns :: Table' a -> Table

-- | Replaces annotations with a unit.
forgetValueAnns :: Value' a -> Value

-- | Extract the top-level annotation from a value.
valueAnn :: Value' a -> a

-- | String representation of the kind of value using TOML vocabulary
valueType :: Value' l -> String
instance GHC.Classes.Eq a => GHC.Classes.Eq (Toml.Semantics.SemanticError a)
instance GHC.Classes.Eq Toml.Semantics.SemanticErrorKind
instance GHC.Internal.Data.Foldable.Foldable Toml.Semantics.SemanticError
instance GHC.Internal.Base.Functor Toml.Semantics.SemanticError
instance GHC.Classes.Ord a => GHC.Classes.Ord (Toml.Semantics.SemanticError a)
instance GHC.Classes.Ord Toml.Semantics.SemanticErrorKind
instance GHC.Internal.Read.Read a => GHC.Internal.Read.Read (Toml.Semantics.SemanticError a)
instance GHC.Internal.Read.Read Toml.Semantics.SemanticErrorKind
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Toml.Semantics.Frame a)
instance GHC.Internal.Show.Show Toml.Semantics.FrameKind
instance GHC.Internal.Show.Show a => GHC.Internal.Show.Show (Toml.Semantics.SemanticError a)
instance GHC.Internal.Show.Show Toml.Semantics.SemanticErrorKind
instance GHC.Internal.Data.Traversable.Traversable Toml.Semantics.SemanticError


-- | The <a>ToValue</a> class provides a conversion function from
--   application-specific to TOML values.
--   
--   Because the top-level TOML document is always a table, the
--   <a>ToTable</a> class is for types that specifically support conversion
--   to a <a>Table</a>.
--   
--   <a>Toml.Schema.Generic</a> can be used to derive instances of
--   <a>ToTable</a> automatically for record types and <a>ToValue</a> for
--   array types.
module Toml.Schema.ToValue

-- | Class for types that can be embedded into <a>Value</a>
class ToValue a

-- | Embed a single thing into a TOML value.
toValue :: ToValue a => a -> Value

-- | Helper for converting a list of things into a value. This is typically
--   left to be defined by its default implementation and exists to help
--   define the encoding for TOML arrays.
toValueList :: ToValue a => [a] -> Value

-- | Class for things that can be embedded into a TOML table.
--   
--   Implement this for things that always embed into a <a>Table</a> and
--   then the <a>ToValue</a> instance can be derived with
--   <a>defaultTableToValue</a>.
--   
--   <pre>
--   instance ToValue Example where
--       toValue = defaultTableToValue
--   
--   -- Option 1: Manual instance
--   instance ToTable Example where
--       toTable x = <a>table</a> ["field1" <a>.=</a> field1 x, "field2" <a>.=</a> field2 x]
--   
--   -- Option 2: GHC.Generics derived instance using Toml.ToValue.Generic
--   instance ToTable Example where
--       toTable = genericToTable
--   </pre>
class ToValue a => ToTable a

-- | Convert a single value into a table
toTable :: ToTable a => a -> Table

-- | Convert to a table key. This class enables various string types to be
--   used as the keys of a <a>Map</a> when converting into TOML tables.
class ToKey a
toKey :: ToKey a => a -> Text

-- | Convenience function for building <a>ToValue</a> instances.
defaultTableToValue :: ToTable a => a -> Value

-- | Build a <a>Table</a> from a list of key-value pairs.
--   
--   Use <a>.=</a> for a convenient way to build the pairs.
table :: [(Text, Value)] -> Table

-- | Convenience function for building key-value pairs while constructing a
--   <a>Table</a>.
--   
--   <pre>
--   <a>table</a> [a <a>.=</a> b, c <a>.=</a> d]
--   </pre>
(.=) :: ToValue a => Text -> a -> (Text, Value)
instance (GHC.Types.Char GHC.Types.~ a) => Toml.Schema.ToValue.ToKey [a]
instance Toml.Schema.ToValue.ToKey Data.Text.Internal.Lazy.Text
instance Toml.Schema.ToValue.ToKey Data.Text.Internal.Text
instance (Toml.Schema.ToValue.ToKey k, Toml.Schema.ToValue.ToValue v) => Toml.Schema.ToValue.ToTable (Data.Map.Internal.Map k v)
instance Toml.Schema.ToValue.ToTable (Toml.Semantics.Types.Table' a)
instance Toml.Schema.ToValue.ToValue GHC.Types.Bool
instance Toml.Schema.ToValue.ToValue GHC.Types.Char
instance Toml.Schema.ToValue.ToValue Data.Time.Calendar.Days.Day
instance Toml.Schema.ToValue.ToValue GHC.Types.Double
instance Toml.Schema.ToValue.ToValue GHC.Types.Float
instance Toml.Schema.ToValue.ToValue GHC.Types.Int
instance Toml.Schema.ToValue.ToValue GHC.Internal.Int.Int16
instance Toml.Schema.ToValue.ToValue GHC.Internal.Int.Int32
instance Toml.Schema.ToValue.ToValue GHC.Internal.Int.Int64
instance Toml.Schema.ToValue.ToValue GHC.Internal.Int.Int8
instance Toml.Schema.ToValue.ToValue GHC.Num.Integer.Integer
instance Toml.Schema.ToValue.ToValue a => Toml.Schema.ToValue.ToValue [a]
instance Toml.Schema.ToValue.ToValue Data.Time.LocalTime.Internal.LocalTime.LocalTime
instance (Toml.Schema.ToValue.ToKey k, Toml.Schema.ToValue.ToValue v) => Toml.Schema.ToValue.ToValue (Data.Map.Internal.Map k v)
instance Toml.Schema.ToValue.ToValue GHC.Num.Natural.Natural
instance Toml.Schema.ToValue.ToValue a => Toml.Schema.ToValue.ToValue (GHC.Internal.Base.NonEmpty a)
instance GHC.Internal.Real.Integral a => Toml.Schema.ToValue.ToValue (GHC.Internal.Real.Ratio a)
instance Toml.Schema.ToValue.ToValue a => Toml.Schema.ToValue.ToValue (Data.Sequence.Internal.Seq a)
instance Toml.Schema.ToValue.ToValue (Toml.Semantics.Types.Table' a)
instance Toml.Schema.ToValue.ToValue Data.Text.Internal.Lazy.Text
instance Toml.Schema.ToValue.ToValue Data.Text.Internal.Text
instance Toml.Schema.ToValue.ToValue Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay
instance Toml.Schema.ToValue.ToValue Data.Time.Clock.Internal.UTCTime.UTCTime
instance Toml.Schema.ToValue.ToValue Toml.Semantics.Types.Value
instance Toml.Schema.ToValue.ToValue GHC.Types.Word
instance Toml.Schema.ToValue.ToValue GHC.Internal.Word.Word16
instance Toml.Schema.ToValue.ToValue GHC.Internal.Word.Word32
instance Toml.Schema.ToValue.ToValue GHC.Internal.Word.Word64
instance Toml.Schema.ToValue.ToValue GHC.Internal.Word.Word8
instance Toml.Schema.ToValue.ToValue Data.Time.LocalTime.Internal.ZonedTime.ZonedTime


-- | Use <a>genericToTable</a> to derive an instance of <a>ToTable</a>
--   using the field names of a record.
--   
--   Use <a>genericToArray</a> to derive an instance of <a>ToValue</a>
--   using the positions of data in a constructor.
module Toml.Schema.Generic.ToValue

-- | Supports conversion of product types with field selector names to TOML
--   values.
class GToTable (f :: Type -> Type)
gToTable :: GToTable f => f a -> [(Text, Value)] -> [(Text, Value)]

-- | Use a record's field names to generate a <a>Table</a>
genericToTable :: (Generic a, GToTable (Rep a)) => a -> Table

-- | Convert product types to arrays positionally.
class GToArray (f :: Type -> Type)
gToArray :: GToArray f => f a -> [Value] -> [Value]

-- | Use a record's field names to generate a <a>Table</a>
genericToArray :: (Generic a, GToArray (Rep a)) => a -> Value
instance (Toml.Schema.Generic.ToValue.GToArray f, Toml.Schema.Generic.ToValue.GToArray g) => Toml.Schema.Generic.ToValue.GToArray (f GHC.Internal.Generics.:*: g)
instance Toml.Schema.ToValue.ToValue a => Toml.Schema.Generic.ToValue.GToArray (GHC.Internal.Generics.K1 i a)
instance Toml.Schema.Generic.ToValue.GToArray f => Toml.Schema.Generic.ToValue.GToArray (GHC.Internal.Generics.M1 i c f)
instance (Toml.Schema.Generic.ToValue.GToTable f, Toml.Schema.Generic.ToValue.GToTable g) => Toml.Schema.Generic.ToValue.GToTable (f GHC.Internal.Generics.:*: g)
instance Toml.Schema.Generic.ToValue.GToTable f => Toml.Schema.Generic.ToValue.GToTable (GHC.Internal.Generics.D1 c f)
instance Toml.Schema.Generic.ToValue.GToTable f => Toml.Schema.Generic.ToValue.GToTable (GHC.Internal.Generics.C1 c f)
instance (GHC.Internal.Generics.Selector s, Toml.Schema.ToValue.ToValue a) => Toml.Schema.Generic.ToValue.GToTable (GHC.Internal.Generics.S1 s (GHC.Internal.Generics.K1 i (GHC.Internal.Maybe.Maybe a)))
instance (GHC.Internal.Generics.Selector s, Toml.Schema.ToValue.ToValue a) => Toml.Schema.Generic.ToValue.GToTable (GHC.Internal.Generics.S1 s (GHC.Internal.Generics.K1 i a))
instance Toml.Schema.Generic.ToValue.GToTable GHC.Internal.Generics.U1
instance Toml.Schema.Generic.ToValue.GToTable GHC.Internal.Generics.V1


-- | This module provides human-readable renderers for types used in this
--   package to assist error message production.
--   
--   The generated <a>Doc</a> values are annotated with <a>DocClass</a>
--   values to assist in producing syntax-highlighted outputs.
--   
--   To extract a plain String representation, use <a>show</a>.
module Toml.Pretty

-- | Pretty-printer document with TOML class attributes to aid in
--   syntax-highlighting.
type TomlDoc = Doc DocClass

-- | Annotation used to enable styling pretty-printed TOML
data DocClass

-- | top-level <tt>[key]</tt> and <tt>[[key]]</tt>
TableClass :: DocClass

-- | dotted keys, left-hand side of assignments
KeyClass :: DocClass

-- | string literals
StringClass :: DocClass

-- | number literals
NumberClass :: DocClass

-- | date and time literals
DateClass :: DocClass

-- | boolean literals
BoolClass :: DocClass

-- | Render a complete TOML document using top-level table and array of
--   table sections where possible.
--   
--   Keys are sorted alphabetically. To provide a custom ordering, see
--   <a>prettyTomlOrdered</a>.
prettyToml :: Table' a -> TomlDoc

-- | Render a complete TOML document like <a>prettyToml</a> but use a
--   custom key ordering. The comparison function has access to the
--   complete key path. Note that only keys in the same table will every be
--   compared.
--   
--   This operation allows you to render your TOML files with the most
--   important sections first. A TOML file describing a package might
--   desire to have the <tt>[package]</tt> section first before any of the
--   ancillary configuration sections.
--   
--   The <i>table path</i> is the name of the table being sorted. This
--   allows the projection to be aware of which table is being sorted.
--   
--   The <i>key</i> is the key in the table being sorted. These are the
--   keys that will be compared to each other.
--   
--   Here's a projection that puts the <tt>package</tt> section first, the
--   <tt>secondary</tt> section second, and then all remaining cases are
--   sorted alphabetically afterward.
--   
--   <pre>
--   example :: [String] -&gt; String -&gt; Either Int String
--   example [] "package" = Left 1
--   example [] "second"  = Left 2
--   example _  other     = Right other
--   </pre>
--   
--   We could also put the tables in reverse-alphabetical order by
--   leveraging an existing newtype.
--   
--   <pre>
--   reverseOrderProj :: [String] -&gt; String -&gt; Down String
--   reverseOrderProj _ = Down
--   </pre>
prettyTomlOrdered :: Ord a => ([Text] -> Text -> a) -> Table' l -> TomlDoc

-- | Render a value suitable for assignment on the right-hand side of an
--   equals sign. This value will always use inline table and list syntax.
prettyValue :: Value' l -> TomlDoc

-- | Render token for human-readable error messages.
prettyToken :: Token -> String

-- | Pretty-print a section heading. The result is annotated as a
--   <a>TableClass</a>.
prettySectionKind :: SectionKind -> NonEmpty Text -> TomlDoc

-- | Renders a simple-key using quotes where necessary.
prettySimpleKey :: Text -> Doc a

-- | Renders a dotted-key using quotes where necessary and annotated as a
--   <a>KeyClass</a>.
prettyKey :: NonEmpty Text -> TomlDoc

-- | Pretty-print as <tt>line:col: message</tt>
prettyLocated :: Located String -> String

-- | Pretty-print as <tt>line:col</tt>
prettyPosition :: Position -> String
instance GHC.Classes.Eq Toml.Pretty.DocClass
instance GHC.Classes.Ord Toml.Pretty.DocClass
instance GHC.Internal.Read.Read Toml.Pretty.DocClass
instance GHC.Internal.Show.Show Toml.Pretty.DocClass


-- | This module parses TOML tokens into a list of raw, uninterpreted
--   sections and assignments.
module Toml.Syntax.Parser

-- | Headers and assignments corresponding to lines of a TOML file
data Expr a

-- | key value assignment: <tt>key = value</tt>
KeyValExpr :: Key a -> Val a -> Expr a

-- | table: <tt>[key]</tt>
TableExpr :: Key a -> Expr a

-- | array of tables: <tt>[[key]]</tt>
ArrayTableExpr :: Key a -> Expr a

-- | Kinds of table headers
data SectionKind

-- | <ul>
--   <li><i>table</i></li>
--   </ul>
TableKind :: SectionKind

-- | <ul>
--   <li><i>[array of tables</i> ]</li>
--   </ul>
ArrayTableKind :: SectionKind

-- | Unvalidated TOML values. Table are represented as a list of
--   assignments rather than as resolved maps.
data Val a
ValInteger :: a -> Integer -> Val a
ValFloat :: a -> Double -> Val a
ValArray :: a -> [Val a] -> Val a
ValTable :: a -> [(Key a, Val a)] -> Val a
ValBool :: a -> Bool -> Val a
ValString :: a -> Text -> Val a
ValTimeOfDay :: a -> TimeOfDay -> Val a
ValZonedTime :: a -> ZonedTime -> Val a
ValLocalTime :: a -> LocalTime -> Val a
ValDay :: a -> Day -> Val a

-- | Non-empty sequence of dotted simple keys
type Key a = NonEmpty (a, Text)

-- | Parse a list of tokens either returning the first unexpected token or
--   a list of the TOML statements in the file to be processed by
--   <a>Toml.Semantics</a>.
parseRawToml :: Text -> Either (Located String) [Expr Position]
instance GHC.Internal.Show.Show Toml.Syntax.Parser.HappyAction


-- | These are the low-level processing functions for transforming concrete
--   TOML syntax into abstract TOML syntax. This module does not do any
--   semantic validation of the parsed TOML.
module Toml.Syntax

-- | Parse a list of tokens either returning the first unexpected token or
--   a list of the TOML statements in the file to be processed by
--   <a>Toml.Semantics</a>.
parseRawToml :: Text -> Either (Located String) [Expr Position]

-- | Non-empty sequence of dotted simple keys
type Key a = NonEmpty (a, Text)

-- | Headers and assignments corresponding to lines of a TOML file
data Expr a

-- | key value assignment: <tt>key = value</tt>
KeyValExpr :: Key a -> Val a -> Expr a

-- | table: <tt>[key]</tt>
TableExpr :: Key a -> Expr a

-- | array of tables: <tt>[[key]]</tt>
ArrayTableExpr :: Key a -> Expr a

-- | Unvalidated TOML values. Table are represented as a list of
--   assignments rather than as resolved maps.
data Val a
ValInteger :: a -> Integer -> Val a
ValFloat :: a -> Double -> Val a
ValArray :: a -> [Val a] -> Val a
ValTable :: a -> [(Key a, Val a)] -> Val a
ValBool :: a -> Bool -> Val a
ValString :: a -> Text -> Val a
ValTimeOfDay :: a -> TimeOfDay -> Val a
ValZonedTime :: a -> ZonedTime -> Val a
ValLocalTime :: a -> LocalTime -> Val a
ValDay :: a -> Day -> Val a

-- | Get the next token from a located string or a located error message.
scanToken :: Context -> Located Text -> Either (Located String) (Located Token, Located Text)

-- | Representation of the current lexer state.
data Context

-- | top-level where <tt>[[</tt> and <tt>]]</tt> have special meaning
TopContext :: Context

-- | inline table - lex key names
TableContext :: Context

-- | value lexer - lex number literals
ValueContext :: Context

-- | multiline basic string: position of opening delimiter and list of
--   fragments
MlBstrContext :: Position -> [Text] -> Context

-- | basic string: position of opening delimiter and list of fragments
BstrContext :: Position -> [Text] -> Context

-- | multiline literal string: position of opening delimiter and list of
--   fragments
MlLstrContext :: Position -> [Text] -> Context

-- | literal string: position of opening delimiter and list of fragments
LstrContext :: Position -> [Text] -> Context

-- | Lexical token
data Token

-- | <pre>
--   true
--   </pre>
TokTrue :: Token

-- | <pre>
--   false
--   </pre>
TokFalse :: Token

-- | <pre>
--   ','
--   </pre>
TokComma :: Token

-- | <pre>
--   '='
--   </pre>
TokEquals :: Token

-- | <pre>
--   end-of-line
--   </pre>
TokNewline :: Token

-- | <pre>
--   <a>.</a>
--   </pre>
TokPeriod :: Token

-- | <pre>
--   '['
--   </pre>
TokSquareO :: Token

-- | <pre>
--   ']'
--   </pre>
TokSquareC :: Token

-- | <pre>
--   '[['
--   </pre>
Tok2SquareO :: Token

-- | <pre>
--   ']]'
--   </pre>
Tok2SquareC :: Token

-- | <pre>
--   '{'
--   </pre>
TokCurlyO :: Token

-- | <pre>
--   '}'
--   </pre>
TokCurlyC :: Token

-- | bare key
TokBareKey :: Text -> Token

-- | string literal
TokString :: Text -> Token

-- | multiline string literal
TokMlString :: Text -> Token

-- | integer literal
TokInteger :: !Integer -> Token

-- | floating-point literal
TokFloat :: !Double -> Token

-- | date-time with timezone offset
TokOffsetDateTime :: !ZonedTime -> Token

-- | local date-time
TokLocalDateTime :: !LocalTime -> Token

-- | local date
TokLocalDate :: !Day -> Token

-- | local time
TokLocalTime :: !TimeOfDay -> Token

-- | <pre>
--   end-of-input
--   </pre>
TokEOF :: Token

-- | A value annotated with its text file position
data Located a
Located :: {-# UNPACK #-} !Position -> !a -> Located a

-- | position
[locPosition] :: Located a -> {-# UNPACK #-} !Position

-- | thing at position
[locThing] :: Located a -> !a

-- | A position in a text file
data Position
Position :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Position

-- | code-point index (zero-based)
[posIndex] :: Position -> {-# UNPACK #-} !Int

-- | line index (one-based)
[posLine] :: Position -> {-# UNPACK #-} !Int

-- | column index (one-based)
[posColumn] :: Position -> {-# UNPACK #-} !Int

-- | The initial <a>Position</a> for the start of a file
startPos :: Position


-- | This module provides utilities for matching key-value pairs out of
--   tables while building up application-specific values.
--   
--   It will help generate warnings for unused keys, help select between
--   multiple possible keys, and emit location-specific error messages when
--   keys are unavailable.
module Toml.Schema.ParseTable

-- | Parser that tracks a current set of unmatched key-value pairs from a
--   table.
--   
--   Use <a>optKey</a> and <a>reqKey</a> to extract keys.
--   
--   Use <a>getTable</a> and <a>setTable</a> to override the table and
--   implement other primitives.
data ParseTable l a

-- | Key and value matching function
data KeyAlt l a

-- | pick alternative based on key match
Key :: Text -> (Value' l -> Matcher l a) -> KeyAlt l a

-- | default case when no previous cases matched
Else :: Matcher l a -> KeyAlt l a

-- | Take the first option from a list of table keys and matcher functions.
--   This operation will commit to the first table key that matches. If the
--   associated matcher fails, only that error will be propagated and the
--   other alternatives will not be matched.
--   
--   If no keys match, an error message is generated explaining which keys
--   would have been accepted.
--   
--   This is provided as an alternative to chaining multiple <a>reqKey</a>
--   cases together with <a>Alternative</a> which will fall-through as a
--   result of any failure to the next case.
pickKey :: [KeyAlt l a] -> ParseTable l a

-- | Run a <a>ParseTable</a> computation with a given starting
--   <a>Table'</a>. Unused tables will generate a warning. To change this
--   behavior <a>getTable</a> and <a>setTable</a> can be used to discard or
--   generate error messages.
parseTable :: ParseTable l a -> l -> Table' l -> Matcher l a

-- | Lift a matcher into the current table parsing context.
liftMatcher :: Matcher l a -> ParseTable l a

-- | Emit a warning without an annotation.
warnTable :: String -> ParseTable l ()

-- | Emit a warning with the given annotation.
warnTableAt :: l -> String -> ParseTable l ()

-- | Abort the current table matching with an error message at the given
--   annotation.
failTableAt :: l -> String -> ParseTable l a

-- | Replace the remaining portion of the table being matched.
setTable :: Table' l -> ParseTable l ()

-- | Return the remaining portion of the table being matched.
getTable :: ParseTable l (Table' l)
instance GHC.Internal.Base.Alternative (Toml.Schema.ParseTable.ParseTable l)
instance GHC.Internal.Base.Applicative (Toml.Schema.ParseTable.ParseTable l)
instance GHC.Internal.Base.Functor (Toml.Schema.ParseTable.ParseTable l)
instance GHC.Internal.Control.Monad.Fail.MonadFail (Toml.Schema.ParseTable.ParseTable l)
instance GHC.Internal.Base.Monad (Toml.Schema.ParseTable.ParseTable l)
instance GHC.Internal.Base.MonadPlus (Toml.Schema.ParseTable.ParseTable l)


-- | Use <a>FromValue</a> to define a transformation from some <a>Value</a>
--   to an application domain type.
--   
--   Use <a>ParseTable</a> to help build <a>FromValue</a> instances that
--   match tables. It will make it easy to track which table keys have been
--   used and which are left over.
--   
--   Warnings can be emitted using <a>warn</a> and <a>warnTable</a>
--   (depending on what) context you're in. These warnings can provide
--   useful feedback about problematic values or keys that might be unused
--   now but were perhaps meaningful in an old version of a configuration
--   file.
--   
--   <a>Toml.Schema.FromValue.Generic</a> can be used to derive instances
--   of <a>FromValue</a> automatically for record types.
module Toml.Schema.FromValue

-- | Class for types that can be decoded from a TOML value.
class FromValue a

-- | Convert a <a>Value</a> or report an error message
fromValue :: FromValue a => Value' l -> Matcher l a

-- | Used to implement instance for <tt>[]</tt>. Most implementations rely
--   on the default implementation.
listFromValue :: FromValue a => Value' l -> Matcher l [a]

-- | Convert from a table key
class FromKey a
fromKey :: FromKey a => l -> Text -> Matcher l a

-- | Table matching function used to help implement <a>fromValue</a> for
--   tables. Key matching function is given the annotation of the key for
--   error reporting. Value matching function is given the key in case
--   values can depend on their keys.
mapOf :: Ord k => (l -> Text -> Matcher l k) -> (Text -> Value' l -> Matcher l v) -> Value' l -> Matcher l (Map k v)

-- | List matching function used to help implemented <a>fromValue</a> for
--   arrays. The element matching function is given the list index in case
--   values can depend on their index.
listOf :: (Int -> Value' l -> Matcher l a) -> Value' l -> Matcher l [a]

-- | Used to derive a <a>fromValue</a> implementation from a
--   <a>ParseTable</a> matcher.
parseTableFromValue :: ParseTable l a -> Value' l -> Matcher l a

-- | Convenience function for matching a required key with a
--   <a>FromValue</a> instance.
--   
--   <pre>
--   reqKey key = <a>reqKeyOf</a> key <a>fromValue</a>
--   </pre>
reqKey :: FromValue a => Text -> ParseTable l a

-- | Match a table entry by key or report an error if missing.
--   
--   See <a>pickKey</a> for more complex cases.
reqKeyOf :: Text -> (Value' l -> Matcher l a) -> ParseTable l a

-- | Convenience function for matching an optional key with a
--   <a>FromValue</a> instance.
--   
--   <pre>
--   optKey key = <a>optKeyOf</a> key <a>fromValue</a>
--   </pre>
optKey :: FromValue a => Text -> ParseTable l (Maybe a)

-- | Match a table entry by key if it exists or return <a>Nothing</a> if
--   not. If the key is defined, it is matched by the given function.
--   
--   See <a>pickKey</a> for more complex cases.
optKeyOf :: Text -> (Value' l -> Matcher l a) -> ParseTable l (Maybe a)

-- | Report a type error
typeError :: String -> Value' l -> Matcher l a
instance (a GHC.Types.~ GHC.Types.Char) => Toml.Schema.FromValue.FromKey [a]
instance Toml.Schema.FromValue.FromKey Data.Text.Internal.Lazy.Text
instance Toml.Schema.FromValue.FromKey Data.Text.Internal.Text
instance Toml.Schema.FromValue.FromValue GHC.Types.Bool
instance Toml.Schema.FromValue.FromValue GHC.Types.Char
instance Toml.Schema.FromValue.FromValue Data.Time.Calendar.Days.Day
instance Toml.Schema.FromValue.FromValue GHC.Types.Double
instance Toml.Schema.FromValue.FromValue GHC.Types.Float
instance Toml.Schema.FromValue.FromValue GHC.Types.Int
instance Toml.Schema.FromValue.FromValue GHC.Internal.Int.Int16
instance Toml.Schema.FromValue.FromValue GHC.Internal.Int.Int32
instance Toml.Schema.FromValue.FromValue GHC.Internal.Int.Int64
instance Toml.Schema.FromValue.FromValue GHC.Internal.Int.Int8
instance Toml.Schema.FromValue.FromValue GHC.Num.Integer.Integer
instance Toml.Schema.FromValue.FromValue a => Toml.Schema.FromValue.FromValue [a]
instance Toml.Schema.FromValue.FromValue Data.Time.LocalTime.Internal.LocalTime.LocalTime
instance (GHC.Classes.Ord k, Toml.Schema.FromValue.FromKey k, Toml.Schema.FromValue.FromValue v) => Toml.Schema.FromValue.FromValue (Data.Map.Internal.Map k v)
instance Toml.Schema.FromValue.FromValue GHC.Num.Natural.Natural
instance Toml.Schema.FromValue.FromValue a => Toml.Schema.FromValue.FromValue (GHC.Internal.Base.NonEmpty a)
instance GHC.Internal.Real.Integral a => Toml.Schema.FromValue.FromValue (GHC.Internal.Real.Ratio a)
instance Toml.Schema.FromValue.FromValue a => Toml.Schema.FromValue.FromValue (Data.Sequence.Internal.Seq a)
instance Toml.Schema.FromValue.FromValue Toml.Semantics.Types.Table
instance Toml.Schema.FromValue.FromValue Data.Text.Internal.Lazy.Text
instance Toml.Schema.FromValue.FromValue Data.Text.Internal.Text
instance Toml.Schema.FromValue.FromValue Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay
instance Toml.Schema.FromValue.FromValue Data.Time.Clock.Internal.UTCTime.UTCTime
instance Toml.Schema.FromValue.FromValue Toml.Semantics.Types.Value
instance Toml.Schema.FromValue.FromValue GHC.Types.Word
instance Toml.Schema.FromValue.FromValue GHC.Internal.Word.Word16
instance Toml.Schema.FromValue.FromValue GHC.Internal.Word.Word32
instance Toml.Schema.FromValue.FromValue GHC.Internal.Word.Word64
instance Toml.Schema.FromValue.FromValue GHC.Internal.Word.Word8
instance Toml.Schema.FromValue.FromValue Data.Time.LocalTime.Internal.ZonedTime.ZonedTime


-- | Generic implementations of matching tables and arrays.
module Toml.Schema.Generic.FromValue

-- | Supports conversion of TOML tables into record values using field
--   selector names as TOML keys.
class GParseTable (f :: Type -> Type)

-- | Convert a value and apply the continuation to the result.
gParseTable :: GParseTable f => ParseTable l (f a)

-- | Match a <a>Table'</a> using the field names in a record.
genericParseTable :: (Generic a, GParseTable (Rep a)) => ParseTable l a

-- | Implementation of <a>fromValue</a> using <a>genericParseTable</a> to
--   derive a match from the record field names of the target type.
genericFromTable :: (Generic a, GParseTable (Rep a)) => Value' l -> Matcher l a

-- | Supports conversion of TOML arrays into product-type values.
class GFromArray (f :: Type -> Type)
gFromArray :: GFromArray f => StateT [Value' l] (Matcher l) (f a)

-- | Match a <a>Value'</a> as an array positionally matching field fields
--   of a constructor to the elements of the array.
genericFromArray :: (Generic a, GFromArray (Rep a)) => Value' l -> Matcher l a
instance (Toml.Schema.Generic.FromValue.GFromArray f, Toml.Schema.Generic.FromValue.GFromArray g) => Toml.Schema.Generic.FromValue.GFromArray (f GHC.Internal.Generics.:*: g)
instance Toml.Schema.FromValue.FromValue a => Toml.Schema.Generic.FromValue.GFromArray (GHC.Internal.Generics.K1 i a)
instance Toml.Schema.Generic.FromValue.GFromArray f => Toml.Schema.Generic.FromValue.GFromArray (GHC.Internal.Generics.M1 i c f)
instance Toml.Schema.Generic.FromValue.GFromArray GHC.Internal.Generics.U1
instance (Toml.Schema.Generic.FromValue.GParseTable f, Toml.Schema.Generic.FromValue.GParseTable g) => Toml.Schema.Generic.FromValue.GParseTable (f GHC.Internal.Generics.:*: g)
instance Toml.Schema.Generic.FromValue.GParseTable f => Toml.Schema.Generic.FromValue.GParseTable (GHC.Internal.Generics.D1 c f)
instance Toml.Schema.Generic.FromValue.GParseTable f => Toml.Schema.Generic.FromValue.GParseTable (GHC.Internal.Generics.C1 ('GHC.Internal.Generics.MetaCons sym fix 'GHC.Types.True) f)
instance (GHC.Internal.Generics.Selector s, Toml.Schema.FromValue.FromValue a) => Toml.Schema.Generic.FromValue.GParseTable (GHC.Internal.Generics.S1 s (GHC.Internal.Generics.K1 i (GHC.Internal.Maybe.Maybe a)))
instance (GHC.Internal.Generics.Selector s, Toml.Schema.FromValue.FromValue a) => Toml.Schema.Generic.FromValue.GParseTable (GHC.Internal.Generics.S1 s (GHC.Internal.Generics.K1 i a))
instance Toml.Schema.Generic.FromValue.GParseTable GHC.Internal.Generics.U1


-- | This module makes it possible to easily derive the TOML classes using
--   the <tt>DerivingVia</tt> extension.
--   
--   For example:
--   
--   <pre>
--   data Physical = Physical {
--       color :: String,
--       shape :: String
--       }
--       deriving (Eq, Show, Generic)
--       deriving (ToTable, ToValue, FromValue) via GenericTomlTable Physical
--   </pre>
--   
--   These derived instances would allow you to match TOML
--   <tt>{color="red", shape="round"}</tt> to value <tt>Physical "red"
--   "round"</tt>.
--   
--   <pre>
--   data Coord = Coord Int Int
--       deriving (Eq, Show, Generic)
--       deriving (ToValue, FromValue) via GenericTomlArray Physical
--   </pre>
--   
--   These derived instances would allow you to match TOML <tt>[1,2]</tt>
--   to value <tt>Coord 1 2</tt>.
module Toml.Schema.Generic

-- | Helper type to use GHC's DerivingVia extension to derive
--   <a>ToValue</a>, <a>ToTable</a>, <a>FromValue</a> for records.
newtype GenericTomlTable a
GenericTomlTable :: a -> GenericTomlTable a

-- | Helper type to use GHC's DerivingVia extension to derive
--   <a>ToValue</a>, <a>ToTable</a>, <a>FromValue</a> for any product type.
newtype GenericTomlArray a
GenericTomlArray :: a -> GenericTomlArray a

-- | Match a <a>Value'</a> as an array positionally matching field fields
--   of a constructor to the elements of the array.
genericFromArray :: (Generic a, GFromArray (Rep a)) => Value' l -> Matcher l a

-- | Implementation of <a>fromValue</a> using <a>genericParseTable</a> to
--   derive a match from the record field names of the target type.
genericFromTable :: (Generic a, GParseTable (Rep a)) => Value' l -> Matcher l a

-- | Supports conversion of TOML arrays into product-type values.
class GFromArray (f :: Type -> Type)

-- | Supports conversion of TOML tables into record values using field
--   selector names as TOML keys.
class GParseTable (f :: Type -> Type)

-- | Use a record's field names to generate a <a>Table</a>
genericToArray :: (Generic a, GToArray (Rep a)) => a -> Value

-- | Use a record's field names to generate a <a>Table</a>
genericToTable :: (Generic a, GToTable (Rep a)) => a -> Table

-- | Convert product types to arrays positionally.
class GToArray (f :: Type -> Type)

-- | Supports conversion of product types with field selector names to TOML
--   values.
class GToTable (f :: Type -> Type)
instance (GHC.Internal.Generics.Generic a, Toml.Schema.Generic.FromValue.GFromArray (GHC.Internal.Generics.Rep a)) => Toml.Schema.FromValue.FromValue (Toml.Schema.Generic.GenericTomlArray a)
instance (GHC.Internal.Generics.Generic a, Toml.Schema.Generic.FromValue.GParseTable (GHC.Internal.Generics.Rep a)) => Toml.Schema.FromValue.FromValue (Toml.Schema.Generic.GenericTomlTable a)
instance (GHC.Internal.Generics.Generic a, Toml.Schema.Generic.ToValue.GToTable (GHC.Internal.Generics.Rep a)) => Toml.Schema.ToValue.ToTable (Toml.Schema.Generic.GenericTomlTable a)
instance (GHC.Internal.Generics.Generic a, Toml.Schema.Generic.ToValue.GToArray (GHC.Internal.Generics.Rep a)) => Toml.Schema.ToValue.ToValue (Toml.Schema.Generic.GenericTomlArray a)
instance (GHC.Internal.Generics.Generic a, Toml.Schema.Generic.ToValue.GToTable (GHC.Internal.Generics.Rep a)) => Toml.Schema.ToValue.ToValue (Toml.Schema.Generic.GenericTomlTable a)


module Toml.Schema

-- | Class for types that can be decoded from a TOML value.
class FromValue a

-- | Convert a <a>Value</a> or report an error message
fromValue :: FromValue a => Value' l -> Matcher l a

-- | Used to implement instance for <tt>[]</tt>. Most implementations rely
--   on the default implementation.
listFromValue :: FromValue a => Value' l -> Matcher l [a]

-- | Table matching function used to help implement <a>fromValue</a> for
--   tables. Key matching function is given the annotation of the key for
--   error reporting. Value matching function is given the key in case
--   values can depend on their keys.
mapOf :: Ord k => (l -> Text -> Matcher l k) -> (Text -> Value' l -> Matcher l v) -> Value' l -> Matcher l (Map k v)

-- | List matching function used to help implemented <a>fromValue</a> for
--   arrays. The element matching function is given the list index in case
--   values can depend on their index.
listOf :: (Int -> Value' l -> Matcher l a) -> Value' l -> Matcher l [a]

-- | Computations that result in a <a>Result</a> and which track a list of
--   nested contexts to assist in generating warnings and error messages.
--   
--   Use <a>withScope</a> to run a <a>Matcher</a> in a new, nested scope.
data Matcher l a

-- | Run a <a>Matcher</a> with an empty scope.
runMatcher :: Matcher l a -> Result (MatchMessage l) a

-- | Run <a>Matcher</a> and treat warnings as errors.
runMatcherFatalWarn :: Matcher l a -> Either [MatchMessage l] a

-- | Run <a>Matcher</a> and ignore warnings.
runMatcherIgnoreWarn :: Matcher l a -> Either [MatchMessage l] a

-- | Computation outcome with error and warning messages. Multiple error
--   messages can occur when multiple alternatives all fail. Resolving any
--   one of the error messages could allow the computation to succeed.
data Result e a

-- | error messages
Failure :: [e] -> Result e a

-- | warning messages and result
Success :: [e] -> a -> Result e a

-- | A message emitted while matching a TOML value. The message is paired
--   with the path to the value that was in focus when the message was
--   generated. These message get used for both warnings and errors.
--   
--   For a convenient way to render these to a string, see
--   <a>prettyMatchMessage</a>.
data MatchMessage a
MatchMessage :: Maybe a -> [Scope] -> String -> MatchMessage a
[matchAnn] :: MatchMessage a -> Maybe a

-- | path to message location
[matchPath] :: MatchMessage a -> [Scope]

-- | error and warning message body
[matchMessage] :: MatchMessage a -> String

-- | Scopes for TOML message.
data Scope

-- | zero-based array index
ScopeIndex :: Int -> Scope

-- | key in a table
ScopeKey :: Text -> Scope

-- | Used to derive a <a>fromValue</a> implementation from a
--   <a>ParseTable</a> matcher.
parseTableFromValue :: ParseTable l a -> Value' l -> Matcher l a

-- | Run a <a>ParseTable</a> computation with a given starting
--   <a>Table'</a>. Unused tables will generate a warning. To change this
--   behavior <a>getTable</a> and <a>setTable</a> can be used to discard or
--   generate error messages.
parseTable :: ParseTable l a -> l -> Table' l -> Matcher l a

-- | Get the current list of scopes.
getScope :: Matcher a [Scope]

-- | Emit a warning without an annotation.
warn :: String -> Matcher a ()

-- | Emit a warning mentioning the given annotation.
warnAt :: l -> String -> Matcher l ()

-- | Terminate the match with an error mentioning the given annotation.
failAt :: l -> String -> Matcher l a

-- | Return the remaining portion of the table being matched.
getTable :: ParseTable l (Table' l)

-- | Replace the remaining portion of the table being matched.
setTable :: Table' l -> ParseTable l ()

-- | Parser that tracks a current set of unmatched key-value pairs from a
--   table.
--   
--   Use <a>optKey</a> and <a>reqKey</a> to extract keys.
--   
--   Use <a>getTable</a> and <a>setTable</a> to override the table and
--   implement other primitives.
data ParseTable l a

-- | Convenience function for matching a required key with a
--   <a>FromValue</a> instance.
--   
--   <pre>
--   reqKey key = <a>reqKeyOf</a> key <a>fromValue</a>
--   </pre>
reqKey :: FromValue a => Text -> ParseTable l a

-- | Convenience function for matching an optional key with a
--   <a>FromValue</a> instance.
--   
--   <pre>
--   optKey key = <a>optKeyOf</a> key <a>fromValue</a>
--   </pre>
optKey :: FromValue a => Text -> ParseTable l (Maybe a)

-- | Match a table entry by key or report an error if missing.
--   
--   See <a>pickKey</a> for more complex cases.
reqKeyOf :: Text -> (Value' l -> Matcher l a) -> ParseTable l a

-- | Match a table entry by key if it exists or return <a>Nothing</a> if
--   not. If the key is defined, it is matched by the given function.
--   
--   See <a>pickKey</a> for more complex cases.
optKeyOf :: Text -> (Value' l -> Matcher l a) -> ParseTable l (Maybe a)

-- | Take the first option from a list of table keys and matcher functions.
--   This operation will commit to the first table key that matches. If the
--   associated matcher fails, only that error will be propagated and the
--   other alternatives will not be matched.
--   
--   If no keys match, an error message is generated explaining which keys
--   would have been accepted.
--   
--   This is provided as an alternative to chaining multiple <a>reqKey</a>
--   cases together with <a>Alternative</a> which will fall-through as a
--   result of any failure to the next case.
pickKey :: [KeyAlt l a] -> ParseTable l a

-- | Key and value matching function
data KeyAlt l a

-- | pick alternative based on key match
Key :: Text -> (Value' l -> Matcher l a) -> KeyAlt l a

-- | default case when no previous cases matched
Else :: Matcher l a -> KeyAlt l a

-- | Emit a warning without an annotation.
warnTable :: String -> ParseTable l ()

-- | Emit a warning with the given annotation.
warnTableAt :: l -> String -> ParseTable l ()

-- | Abort the current table matching with an error message at the given
--   annotation.
failTableAt :: l -> String -> ParseTable l a

-- | Lift a matcher into the current table parsing context.
liftMatcher :: Matcher l a -> ParseTable l a

-- | Class for types that can be embedded into <a>Value</a>
class ToValue a

-- | Embed a single thing into a TOML value.
toValue :: ToValue a => a -> Value

-- | Helper for converting a list of things into a value. This is typically
--   left to be defined by its default implementation and exists to help
--   define the encoding for TOML arrays.
toValueList :: ToValue a => [a] -> Value

-- | Class for things that can be embedded into a TOML table.
--   
--   Implement this for things that always embed into a <a>Table</a> and
--   then the <a>ToValue</a> instance can be derived with
--   <a>defaultTableToValue</a>.
--   
--   <pre>
--   instance ToValue Example where
--       toValue = defaultTableToValue
--   
--   -- Option 1: Manual instance
--   instance ToTable Example where
--       toTable x = <a>table</a> ["field1" <a>.=</a> field1 x, "field2" <a>.=</a> field2 x]
--   
--   -- Option 2: GHC.Generics derived instance using Toml.ToValue.Generic
--   instance ToTable Example where
--       toTable = genericToTable
--   </pre>
class ToValue a => ToTable a

-- | Convert a single value into a table
toTable :: ToTable a => a -> Table

-- | Build a <a>Table</a> from a list of key-value pairs.
--   
--   Use <a>.=</a> for a convenient way to build the pairs.
table :: [(Text, Value)] -> Table

-- | Convenience function for building key-value pairs while constructing a
--   <a>Table</a>.
--   
--   <pre>
--   <a>table</a> [a <a>.=</a> b, c <a>.=</a> d]
--   </pre>
(.=) :: ToValue a => Text -> a -> (Text, Value)

-- | Convenience function for building <a>ToValue</a> instances.
defaultTableToValue :: ToTable a => a -> Value

-- | A <a>Value'</a> with trivial annotations
type Value = Value' ()

-- | Semantic TOML value with all table assignments resolved.
data Value' a
Integer' :: a -> Integer -> Value' a
Double' :: a -> Double -> Value' a
List' :: a -> [Value' a] -> Value' a
Table' :: a -> Table' a -> Value' a
Bool' :: a -> Bool -> Value' a
Text' :: a -> Text -> Value' a
TimeOfDay' :: a -> TimeOfDay -> Value' a
ZonedTime' :: a -> ZonedTime -> Value' a
LocalTime' :: a -> LocalTime -> Value' a
Day' :: a -> Day -> Value' a
pattern Bool :: Bool -> Value
pattern Day :: Day -> Value
pattern Double :: Double -> Value
pattern Integer :: Integer -> Value
pattern List :: [Value] -> Value
pattern LocalTime :: LocalTime -> Value
pattern Table :: Table -> Value
pattern Text :: Text -> Value
pattern TimeOfDay :: TimeOfDay -> Value
pattern ZonedTime :: ZonedTime -> Value

-- | A <a>Table'</a> with trivial annotations
type Table = Table' ()

-- | A table with annotated keys and values.
newtype Table' a
MkTable :: Map Text (a, Value' a) -> Table' a

-- | Helper type to use GHC's DerivingVia extension to derive
--   <a>ToValue</a>, <a>ToTable</a>, <a>FromValue</a> for any product type.
newtype GenericTomlArray a
GenericTomlArray :: a -> GenericTomlArray a

-- | Helper type to use GHC's DerivingVia extension to derive
--   <a>ToValue</a>, <a>ToTable</a>, <a>FromValue</a> for records.
newtype GenericTomlTable a
GenericTomlTable :: a -> GenericTomlTable a

-- | Implementation of <a>fromValue</a> using <a>genericParseTable</a> to
--   derive a match from the record field names of the target type.
genericFromTable :: (Generic a, GParseTable (Rep a)) => Value' l -> Matcher l a

-- | Match a <a>Value'</a> as an array positionally matching field fields
--   of a constructor to the elements of the array.
genericFromArray :: (Generic a, GFromArray (Rep a)) => Value' l -> Matcher l a

-- | Use a record's field names to generate a <a>Table</a>
genericToArray :: (Generic a, GToArray (Rep a)) => a -> Value

-- | Use a record's field names to generate a <a>Table</a>
genericToTable :: (Generic a, GToTable (Rep a)) => a -> Table


-- | This is the high-level interface to the toml-parser library. It
--   enables parsing, printing, and conversion into and out of
--   application-specific representations.
--   
--   This parser implements TOML 1.1.0 <a>https://toml.io/en/v1.1.0</a> as
--   carefully as possible.
--   
--   Use <a>Toml.Schema</a> to implement functions mapping between TOML
--   values and your application types.
--   
--   Use <a>Toml.Syntax</a> and <a>Toml.Semantics</a> for low-level TOML
--   syntax processing and semantic validation. Most applications will not
--   need to use these modules directly unless the application is about
--   TOML itself.
--   
--   The types and functions of this package are parameterized over an
--   annotation type in order to allow applications to provide detailed
--   feedback messages tracked back to specific source locations in an
--   original TOML file. While the default annotation is a simple file
--   position, some applications might upgrade this annotation to track
--   multiple file names or synthetically generated sources. Other
--   applications won't need source location and can replace annotations
--   with a simple unit type.
module Toml

-- | A <a>Table'</a> with trivial annotations
type Table = Table' ()

-- | A <a>Value'</a> with trivial annotations
type Value = Value' ()

-- | A value annotated with its text file position
data Located a
Located :: {-# UNPACK #-} !Position -> !a -> Located a

-- | position
[locPosition] :: Located a -> {-# UNPACK #-} !Position

-- | thing at position
[locThing] :: Located a -> !a

-- | A position in a text file
data Position
Position :: {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> Position

-- | code-point index (zero-based)
[posIndex] :: Position -> {-# UNPACK #-} !Int

-- | line index (one-based)
[posLine] :: Position -> {-# UNPACK #-} !Int

-- | column index (one-based)
[posColumn] :: Position -> {-# UNPACK #-} !Int

-- | A table with annotated keys and values.
newtype Table' a
MkTable :: Map Text (a, Value' a) -> Table' a

-- | Semantic TOML value with all table assignments resolved.
data Value' a
Integer' :: a -> Integer -> Value' a
Double' :: a -> Double -> Value' a
List' :: a -> [Value' a] -> Value' a
Table' :: a -> Table' a -> Value' a
Bool' :: a -> Bool -> Value' a
Text' :: a -> Text -> Value' a
TimeOfDay' :: a -> TimeOfDay -> Value' a
ZonedTime' :: a -> ZonedTime -> Value' a
LocalTime' :: a -> LocalTime -> Value' a
Day' :: a -> Day -> Value' a
pattern Bool :: Bool -> Value
pattern Day :: Day -> Value
pattern Double :: Double -> Value
pattern Integer :: Integer -> Value
pattern List :: [Value] -> Value
pattern LocalTime :: LocalTime -> Value
pattern Table :: Table -> Value
pattern Text :: Text -> Value
pattern TimeOfDay :: TimeOfDay -> Value
pattern ZonedTime :: ZonedTime -> Value

-- | Extract the top-level annotation from a value.
valueAnn :: Value' a -> a

-- | String representation of the kind of value using TOML vocabulary
valueType :: Value' l -> String

-- | Replaces annotations with a unit.
forgetTableAnns :: Table' a -> Table

-- | Replaces annotations with a unit.
forgetValueAnns :: Value' a -> Value

-- | Decode TOML syntax into an application value.
decode' :: FromValue a => Text -> Result DecodeError a

-- | Wrapper rending error and warning messages into human-readable
--   strings.
decode :: FromValue a => Text -> Result String a

-- | Parse a TOML formatted <a>String</a> or report a human-readable error
--   message.
parse :: Text -> Either String (Table' Position)

-- | Sum of errors that can occur during TOML decoding
data DecodeError

-- | Computation outcome with error and warning messages. Multiple error
--   messages can occur when multiple alternatives all fail. Resolving any
--   one of the error messages could allow the computation to succeed.
data Result e a

-- | error messages
Failure :: [e] -> Result e a

-- | warning messages and result
Success :: [e] -> a -> Result e a

-- | Use the <a>ToTable</a> instance to encode a value to a TOML string.
encode :: ToTable a => a -> TomlDoc

-- | Render a complete TOML document using top-level table and array of
--   table sections where possible.
--   
--   Keys are sorted alphabetically. To provide a custom ordering, see
--   <a>prettyTomlOrdered</a>.
prettyToml :: Table' a -> TomlDoc

-- | Annotation used to enable styling pretty-printed TOML
data DocClass

-- | top-level <tt>[key]</tt> and <tt>[[key]]</tt>
TableClass :: DocClass

-- | dotted keys, left-hand side of assignments
KeyClass :: DocClass

-- | string literals
StringClass :: DocClass

-- | number literals
NumberClass :: DocClass

-- | date and time literals
DateClass :: DocClass

-- | boolean literals
BoolClass :: DocClass

-- | Human-readable representation of a <a>DecodeError</a>
prettyDecodeError :: DecodeError -> String

-- | Pretty-print as <tt>line:col: message</tt>
prettyLocated :: Located String -> String

-- | Render a TOML decoding error as a human-readable string.
prettyMatchMessage :: MatchMessage Position -> String

-- | Render a semantic TOML error in a human-readable string.
prettySemanticError :: SemanticError Position -> String
