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


-- | TOML format parser compliant with v1.0.0.
--   
--   TOML format parser compliant with v1.0.0. See README.md for more
--   details.
@package toml-reader
@version 0.2.0.0

module TOML.Utils.NonEmpty

-- | Annotates each element with the history of all past elements.
--   
--   <pre>
--   &gt;&gt;&gt; zipHistory ["a", "b", "c"]
--   [(["a"], "a"), (["a", "b"], "b"), (["a", "b", "c"], "c")]
--   </pre>
zipHistory :: NonEmpty a -> NonEmpty (NonEmpty a, a)

module TOML.Utils.Map

-- | For a non-empty list of keys, iterate through the given <a>Map</a> and
--   return the possibly missing value at the path and a function to set
--   the value at the given path and return the modified input <a>Map</a>.
--   
--   <pre>
--   let obj = undefined -- { "a": { "b": { "c": 1 } } }
--   (mValue, setValue) &lt;- getPathLens doRecurse ["a", "b", "c"] obj
--   
--   print mValue -- Just 1
--   print (setValue 2) -- { "a": { "b": { "c": 2 } } }
--   </pre>
getPathLens :: (Monad m, Ord k) => (NonEmpty k -> Maybe v -> m (Map k v, Map k v -> v)) -> NonEmpty k -> Map k v -> m (Maybe v, v -> Map k v)

-- | Same as <a>getPathLens</a>, except without the setter.
getPath :: (Monad m, Ord k) => (NonEmpty k -> Maybe v -> m (Map k v)) -> NonEmpty k -> Map k v -> m (Maybe v)

module TOML.Value
data Value
Table :: Table -> Value
Array :: [Value] -> Value
String :: Text -> Value
Integer :: Integer -> Value
Float :: Double -> Value
Boolean :: Bool -> Value
OffsetDateTime :: (LocalTime, TimeZone) -> Value
LocalDateTime :: LocalTime -> Value
LocalDate :: Day -> Value
LocalTime :: TimeOfDay -> Value

-- | Render a Value in pseudo-JSON format.
renderValue :: Value -> Text
type Table = Map Text Value
instance GHC.Classes.Eq TOML.Value.Value
instance GHC.Show.Show TOML.Value.Value

module TOML.Error
data TOMLError
ParseError :: Text -> TOMLError
NormalizeError :: NormalizeError -> TOMLError
DecodeError :: DecodeContext -> DecodeError -> TOMLError
data NormalizeError

-- | When a key is defined twice, e.g.
--   
--   <pre>
--   name = <tt>First</tt>
--   name = <tt>Second</tt>
--   </pre>
DuplicateKeyError :: NonEmpty Text -> Value -> Value -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_existingValue] :: NormalizeError -> Value
[_valueToSet] :: NormalizeError -> Value

-- | When a section is defined twice, e.g.
--   
--   <pre>
--   [foo]
--   a = 1
--   
--   [foo]
--   b = 2
--   </pre>
DuplicateSectionError :: NonEmpty Text -> NormalizeError
[_sectionKey] :: NormalizeError -> NonEmpty Text

-- | When a key attempts to extend an invalid table
--   
--   <pre>
--   a = {}
--   [a.b]
--   
--   b = {}
--   b.a = 1
--   
--   c.x.x = 1
--   [c.a]
--   </pre>
ExtendTableError :: NonEmpty Text -> NonEmpty Text -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_originalKey] :: NormalizeError -> NonEmpty Text

-- | When a section attempts to extend a table within an inline array
--   
--   <pre>
--   a = [{ b = 1 }]
--   [a.c]
--   </pre>
ExtendTableInInlineArrayError :: NonEmpty Text -> NonEmpty Text -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_originalKey] :: NormalizeError -> NonEmpty Text

-- | When a key is already defined, but attempting to create an implicit
--   array at the same key, e.g.
--   
--   <pre>
--   list = [1, 2, 3]
--   
--   [[list]]
--   a = 1
--   </pre>
ImplicitArrayForDefinedKeyError :: NonEmpty Text -> Value -> Table -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_existingValue] :: NormalizeError -> Value
[_tableSection] :: NormalizeError -> Table

-- | When a non-table value is already defined in a nested key, e.g.
--   
--   <pre>
--   a.b = 1
--   a.b.c.d = 2
--   </pre>
NonTableInNestedKeyError :: NonEmpty Text -> Value -> NonEmpty Text -> Value -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_existingValue] :: NormalizeError -> Value
[_originalKey] :: NormalizeError -> NonEmpty Text
[_originalValue] :: NormalizeError -> Value

-- | When a non-table value is already defined in a nested implicit array,
--   e.g.
--   
--   <pre>
--   a.b = 1
--   
--   [[a.b.c]]
--   d = 2
--   </pre>
NonTableInNestedImplicitArrayError :: NonEmpty Text -> Value -> NonEmpty Text -> Table -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_existingValue] :: NormalizeError -> Value
[_sectionKey] :: NormalizeError -> NonEmpty Text
[_tableSection] :: NormalizeError -> Table
type DecodeContext = [ContextItem]
data ContextItem
Key :: Text -> ContextItem
Index :: Int -> ContextItem
data DecodeError
MissingField :: DecodeError
InvalidValue :: Text -> Value -> DecodeError
TypeMismatch :: Value -> DecodeError
OtherDecodeError :: Text -> DecodeError
renderTOMLError :: TOMLError -> Text
instance GHC.Classes.Eq TOML.Error.NormalizeError
instance GHC.Show.Show TOML.Error.NormalizeError
instance GHC.Classes.Eq TOML.Error.ContextItem
instance GHC.Show.Show TOML.Error.ContextItem
instance GHC.Classes.Eq TOML.Error.DecodeError
instance GHC.Show.Show TOML.Error.DecodeError
instance GHC.Classes.Eq TOML.Error.TOMLError
instance GHC.Show.Show TOML.Error.TOMLError
instance GHC.Exception.Type.Exception TOML.Error.TOMLError


-- | Parse a TOML document.
--   
--   References:
--   
--   <ul>
--   <li><a>https://toml.io/en/v1.0.0</a></li>
--   <li><a>https://github.com/toml-lang/toml/blob/1.0.0/toml.abnf</a></li>
--   </ul>
module TOML.Parser
parseTOML :: String -> Text -> Either TOMLError Value
instance GHC.Classes.Eq TOML.Parser.TableType
instance GHC.Base.Functor TOML.Parser.NormalizeM
instance GHC.Base.Applicative TOML.Parser.NormalizeM
instance GHC.Base.Monad TOML.Parser.NormalizeM

module TOML.Decode

-- | Decode the given TOML input.
decode :: DecodeTOML a => Text -> Either TOMLError a

-- | Decode the given TOML input using the given <a>Decoder</a>.
decodeWith :: Decoder a -> Text -> Either TOMLError a
decodeWithOpts :: Decoder a -> String -> Text -> Either TOMLError a

-- | Decode a TOML file at the given file path.
decodeFile :: DecodeTOML a => FilePath -> IO (Either TOMLError a)

-- | A type class containing the default <a>Decoder</a> for the given type.
--   
--   See the docs for <a>Decoder</a> for examples.
class DecodeTOML a
tomlDecoder :: DecodeTOML a => Decoder a

-- | A <tt>Decoder a</tt> represents a function for decoding a TOML value
--   to a value of type <tt>a</tt>.
--   
--   Generally, you'd only need to chain the <tt>getField*</tt> functions
--   together, like
--   
--   <pre>
--   decoder =
--     MyConfig
--       &lt;$&gt; getField "a"
--       &lt;*&gt; getField "b"
--       &lt;*&gt; getField "c"
--   </pre>
--   
--   or use interfaces like <a>Monad</a> and <a>Alternative</a>:
--   
--   <pre>
--   decoder = do
--     cfgType &lt;- getField "type"
--     case cfgType of
--       "int" -&gt; MyIntValue &lt;$&gt; (getField "int" &lt;|&gt; getField "integer")
--       "bool" -&gt; MyBoolValue &lt;$&gt; getField "bool"
--       _ -&gt; fail $ "Invalid type: " &lt;&gt; cfgType
--   </pre>
--   
--   but you can also manually implement a <a>Decoder</a> with
--   <a>makeDecoder</a>.
newtype Decoder a
Decoder :: (Value -> DecodeM a) -> Decoder a
[unDecoder] :: Decoder a -> Value -> DecodeM a

-- | Decode a field in a TOML Value. Equivalent to <a>getFields</a> with a
--   single-element list.
--   
--   <pre>
--   a = 1
--   b = <tt>asdf</tt>
--   </pre>
--   
--   <pre>
--   -- MyConfig 1 "asdf"
--   MyConfig &lt;$&gt; getField "a" &lt;*&gt; getField "b"
--   </pre>
getField :: DecodeTOML a => Text -> Decoder a

-- | Decode a field in a TOML Value or succeed with a default value when
--   the field is missing.
--   
--   <pre>
--   a = 1
--   # b is missing
--   </pre>
--   
--   <pre>
--   -- MyConfig 1 "asdf"
--   MyConfig &lt;$&gt; getFieldOr 42 "a" &lt;*&gt; getFieldOr "asdf" "b"
--   </pre>
getFieldOr :: DecodeTOML a => a -> Text -> Decoder a

-- | Decode a nested field in a TOML Value.
--   
--   <pre>
--   a.b = 1
--   </pre>
--   
--   <pre>
--   -- MyConfig 1
--   MyConfig &lt;$&gt; getFields ["a", "b"]
--   </pre>
getFields :: DecodeTOML a => [Text] -> Decoder a

-- | Decode a field in a TOML Value, or Nothing if the field doesn't exist.
--   Equivalent to <a>getFieldsOpt</a> with a single-element list.
--   
--   <pre>
--   a = 1
--   </pre>
--   
--   <pre>
--   -- MyConfig (Just 1) Nothing
--   MyConfig &lt;$&gt; getFieldOpt "a" &lt;*&gt; getFieldOpt "b"
--   </pre>
getFieldOpt :: DecodeTOML a => Text -> Decoder (Maybe a)

-- | Decode a nested field in a TOML Value, or <a>Nothing</a> if any of the
--   fields don't exist.
--   
--   <pre>
--   a.b = 1
--   </pre>
--   
--   <pre>
--   -- MyConfig (Just 1) Nothing Nothing
--   MyConfig
--     &lt;$&gt; getFieldsOpt ["a", "b"]
--     &lt;*&gt; getFieldsOpt ["a", "c"]
--     &lt;*&gt; getFieldsOpt ["b", "c"]
--   </pre>
getFieldsOpt :: DecodeTOML a => [Text] -> Decoder (Maybe a)

-- | Same as <a>getField</a>, except with the given <a>Decoder</a>.
getFieldWith :: Decoder a -> Text -> Decoder a

-- | Same as <a>getFields</a>, except with the given <a>Decoder</a>.
getFieldsWith :: Decoder a -> [Text] -> Decoder a

-- | Same as <a>getFieldOpt</a>, except with the given <a>Decoder</a>.
getFieldOptWith :: Decoder a -> Text -> Decoder (Maybe a)

-- | Same as <a>getFieldsOpt</a>, except with the given <a>Decoder</a>.
getFieldsOptWith :: Decoder a -> [Text] -> Decoder (Maybe a)

-- | Decode a list of values using the given <a>Decoder</a>.
--   
--   <pre>
--   [[a]]
--   b = 1
--   
--   [[a]]
--   b = 2
--   </pre>
--   
--   <pre>
--   -- MyConfig [1, 2]
--   MyConfig
--     &lt;$&gt; getFieldWith (getArrayOf (getField "b")) "a"
--   </pre>
getArrayOf :: Decoder a -> Decoder [a]

-- | The underlying decoding monad that either returns a value of type
--   <tt>a</tt> or returns an error.
newtype DecodeM a
DecodeM :: (DecodeContext -> Either (DecodeContext, DecodeError) a) -> DecodeM a
[unDecodeM] :: DecodeM a -> DecodeContext -> Either (DecodeContext, DecodeError) a

-- | Manually implement a <a>Decoder</a> with the given function.
makeDecoder :: (Value -> DecodeM a) -> Decoder a

-- | Run a <a>Decoder</a> with the given <a>Value</a>.
--   
--   <pre>
--   makeDecoder $ \v -&gt; do
--     a &lt;- runDecoder decoder1 v
--     b &lt;- runDecoder decoder2 v
--     return (a, b)
--   </pre>
--   
--   Satisfies
--   
--   <pre>
--   makeDecoder . runDecoder === id
--   runDecoder . makeDecoder === id
--   </pre>
runDecoder :: Decoder a -> Value -> DecodeM a
addContextItem :: ContextItem -> DecodeM a -> DecodeM a

-- | Throw an error indicating that the given <a>Value</a> is invalid.
--   
--   <pre>
--   makeDecoder $ \v -&gt;
--     case v of
--       Integer 42 -&gt; invalidValue "We don't like this number" v
--       _ -&gt; runDecoder tomlDecoder v
--   
--   -- or alternatively,
--   tomlDecoder &gt;&gt;= case
--     42 -&gt; makeDecoder $ invalidValue "We don't like this number"
--     v -&gt; pure v
--   </pre>
invalidValue :: Text -> Value -> DecodeM a

-- | Throw an error indicating that the given <a>Value</a> isn't the
--   correct type of value.
--   
--   <pre>
--   makeDecoder $ \v -&gt;
--     case v of
--       String s -&gt; ...
--       _ -&gt; typeMismatch v
--   </pre>
typeMismatch :: Value -> DecodeM a

-- | Throw a generic failure message.
decodeFail :: Text -> DecodeM a

-- | Throw the given <a>DecodeError</a>.
decodeError :: DecodeError -> DecodeM a
instance TOML.Decode.DecodeTOML TOML.Value.Value
instance TOML.Decode.DecodeTOML Data.Void.Void
instance TOML.Decode.DecodeTOML GHC.Types.Bool
instance TOML.Decode.DecodeTOML GHC.Integer.Type.Integer
instance TOML.Decode.DecodeTOML GHC.Types.Int
instance TOML.Decode.DecodeTOML GHC.Int.Int8
instance TOML.Decode.DecodeTOML GHC.Int.Int16
instance TOML.Decode.DecodeTOML GHC.Int.Int32
instance TOML.Decode.DecodeTOML GHC.Int.Int64
instance TOML.Decode.DecodeTOML GHC.Types.Word
instance TOML.Decode.DecodeTOML GHC.Word.Word8
instance TOML.Decode.DecodeTOML GHC.Word.Word16
instance TOML.Decode.DecodeTOML GHC.Word.Word32
instance TOML.Decode.DecodeTOML GHC.Word.Word64
instance TOML.Decode.DecodeTOML GHC.Natural.Natural
instance TOML.Decode.DecodeTOML GHC.Types.Double
instance TOML.Decode.DecodeTOML GHC.Types.Float
instance GHC.Real.Integral a => TOML.Decode.DecodeTOML (GHC.Real.Ratio a)
instance Data.Fixed.HasResolution a => TOML.Decode.DecodeTOML (Data.Fixed.Fixed a)
instance TOML.Decode.DecodeTOML GHC.Types.Char
instance TOML.Decode.DecodeTOML GHC.Base.String
instance TOML.Decode.DecodeTOML Data.Text.Internal.Text
instance TOML.Decode.DecodeTOML Data.Text.Internal.Lazy.Text
instance TOML.Decode.DecodeTOML Data.Time.LocalTime.Internal.ZonedTime.ZonedTime
instance TOML.Decode.DecodeTOML Data.Time.Clock.Internal.UTCTime.UTCTime
instance TOML.Decode.DecodeTOML Data.Time.Clock.Internal.SystemTime.SystemTime
instance TOML.Decode.DecodeTOML Data.Time.LocalTime.Internal.LocalTime.LocalTime
instance TOML.Decode.DecodeTOML Data.Time.Calendar.Days.Day
instance TOML.Decode.DecodeTOML Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay
instance TOML.Decode.DecodeTOML Data.Time.Calendar.Week.DayOfWeek
instance TOML.Decode.DecodeTOML Data.Time.Clock.Internal.DiffTime.DiffTime
instance TOML.Decode.DecodeTOML Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime
instance TOML.Decode.DecodeTOML Data.Time.LocalTime.Internal.CalendarDiffTime.CalendarDiffTime
instance TOML.Decode.DecodeTOML Data.Time.Calendar.CalendarDiffDays.CalendarDiffDays
instance TOML.Decode.DecodeTOML Data.Version.Version
instance TOML.Decode.DecodeTOML GHC.Types.Ordering
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Functor.Identity.Identity a)
instance TOML.Decode.DecodeTOML (Data.Proxy.Proxy a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Functor.Const.Const a b)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (GHC.Maybe.Maybe a)
instance (TOML.Decode.DecodeTOML a, TOML.Decode.DecodeTOML b) => TOML.Decode.DecodeTOML (Data.Either.Either a b)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Monoid.First a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Monoid.Last a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Semigroup.First a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Semigroup.Last a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Semigroup.Max a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Semigroup.Min a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Semigroup.Internal.Dual a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML [a]
instance (Data.String.IsString k, GHC.Classes.Ord k, TOML.Decode.DecodeTOML v) => TOML.Decode.DecodeTOML (Data.Map.Internal.Map k v)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (GHC.Base.NonEmpty a)
instance TOML.Decode.DecodeTOML Data.IntSet.Internal.IntSet
instance (TOML.Decode.DecodeTOML a, GHC.Classes.Ord a) => TOML.Decode.DecodeTOML (Data.Set.Internal.Set a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.IntMap.Internal.IntMap a)
instance TOML.Decode.DecodeTOML a => TOML.Decode.DecodeTOML (Data.Sequence.Internal.Seq a)
instance TOML.Decode.DecodeTOML ()
instance (TOML.Decode.DecodeTOML a, TOML.Decode.DecodeTOML b) => TOML.Decode.DecodeTOML (a, b)
instance (TOML.Decode.DecodeTOML a, TOML.Decode.DecodeTOML b, TOML.Decode.DecodeTOML c) => TOML.Decode.DecodeTOML (a, b, c)
instance (TOML.Decode.DecodeTOML a, TOML.Decode.DecodeTOML b, TOML.Decode.DecodeTOML c, TOML.Decode.DecodeTOML d) => TOML.Decode.DecodeTOML (a, b, c, d)
instance GHC.Base.Functor TOML.Decode.Decoder
instance GHC.Base.Applicative TOML.Decode.Decoder
instance GHC.Base.Monad TOML.Decode.Decoder
instance GHC.Base.Alternative TOML.Decode.Decoder
instance Control.Monad.Fail.MonadFail TOML.Decode.Decoder
instance GHC.Base.Functor TOML.Decode.DecodeM
instance GHC.Base.Applicative TOML.Decode.DecodeM
instance GHC.Base.Monad TOML.Decode.DecodeM
instance GHC.Base.Alternative TOML.Decode.DecodeM
instance Control.Monad.Fail.MonadFail TOML.Decode.DecodeM

module TOML

-- | Decode the given TOML input.
decode :: DecodeTOML a => Text -> Either TOMLError a

-- | Decode the given TOML input using the given <a>Decoder</a>.
decodeWith :: Decoder a -> Text -> Either TOMLError a

-- | Decode a TOML file at the given file path.
decodeFile :: DecodeTOML a => FilePath -> IO (Either TOMLError a)

-- | A type class containing the default <a>Decoder</a> for the given type.
--   
--   See the docs for <a>Decoder</a> for examples.
class DecodeTOML a
tomlDecoder :: DecodeTOML a => Decoder a

-- | A <tt>Decoder a</tt> represents a function for decoding a TOML value
--   to a value of type <tt>a</tt>.
--   
--   Generally, you'd only need to chain the <tt>getField*</tt> functions
--   together, like
--   
--   <pre>
--   decoder =
--     MyConfig
--       &lt;$&gt; getField "a"
--       &lt;*&gt; getField "b"
--       &lt;*&gt; getField "c"
--   </pre>
--   
--   or use interfaces like <a>Monad</a> and <a>Alternative</a>:
--   
--   <pre>
--   decoder = do
--     cfgType &lt;- getField "type"
--     case cfgType of
--       "int" -&gt; MyIntValue &lt;$&gt; (getField "int" &lt;|&gt; getField "integer")
--       "bool" -&gt; MyBoolValue &lt;$&gt; getField "bool"
--       _ -&gt; fail $ "Invalid type: " &lt;&gt; cfgType
--   </pre>
--   
--   but you can also manually implement a <a>Decoder</a> with
--   <a>makeDecoder</a>.
data Decoder a

-- | Decode a field in a TOML Value. Equivalent to <a>getFields</a> with a
--   single-element list.
--   
--   <pre>
--   a = 1
--   b = <tt>asdf</tt>
--   </pre>
--   
--   <pre>
--   -- MyConfig 1 "asdf"
--   MyConfig &lt;$&gt; getField "a" &lt;*&gt; getField "b"
--   </pre>
getField :: DecodeTOML a => Text -> Decoder a

-- | Decode a field in a TOML Value or succeed with a default value when
--   the field is missing.
--   
--   <pre>
--   a = 1
--   # b is missing
--   </pre>
--   
--   <pre>
--   -- MyConfig 1 "asdf"
--   MyConfig &lt;$&gt; getFieldOr 42 "a" &lt;*&gt; getFieldOr "asdf" "b"
--   </pre>
getFieldOr :: DecodeTOML a => a -> Text -> Decoder a

-- | Decode a nested field in a TOML Value.
--   
--   <pre>
--   a.b = 1
--   </pre>
--   
--   <pre>
--   -- MyConfig 1
--   MyConfig &lt;$&gt; getFields ["a", "b"]
--   </pre>
getFields :: DecodeTOML a => [Text] -> Decoder a

-- | Decode a field in a TOML Value, or Nothing if the field doesn't exist.
--   Equivalent to <a>getFieldsOpt</a> with a single-element list.
--   
--   <pre>
--   a = 1
--   </pre>
--   
--   <pre>
--   -- MyConfig (Just 1) Nothing
--   MyConfig &lt;$&gt; getFieldOpt "a" &lt;*&gt; getFieldOpt "b"
--   </pre>
getFieldOpt :: DecodeTOML a => Text -> Decoder (Maybe a)

-- | Decode a nested field in a TOML Value, or <a>Nothing</a> if any of the
--   fields don't exist.
--   
--   <pre>
--   a.b = 1
--   </pre>
--   
--   <pre>
--   -- MyConfig (Just 1) Nothing Nothing
--   MyConfig
--     &lt;$&gt; getFieldsOpt ["a", "b"]
--     &lt;*&gt; getFieldsOpt ["a", "c"]
--     &lt;*&gt; getFieldsOpt ["b", "c"]
--   </pre>
getFieldsOpt :: DecodeTOML a => [Text] -> Decoder (Maybe a)

-- | Same as <a>getField</a>, except with the given <a>Decoder</a>.
getFieldWith :: Decoder a -> Text -> Decoder a

-- | Same as <a>getFields</a>, except with the given <a>Decoder</a>.
getFieldsWith :: Decoder a -> [Text] -> Decoder a

-- | Same as <a>getFieldOpt</a>, except with the given <a>Decoder</a>.
getFieldOptWith :: Decoder a -> Text -> Decoder (Maybe a)

-- | Same as <a>getFieldsOpt</a>, except with the given <a>Decoder</a>.
getFieldsOptWith :: Decoder a -> [Text] -> Decoder (Maybe a)

-- | Decode a list of values using the given <a>Decoder</a>.
--   
--   <pre>
--   [[a]]
--   b = 1
--   
--   [[a]]
--   b = 2
--   </pre>
--   
--   <pre>
--   -- MyConfig [1, 2]
--   MyConfig
--     &lt;$&gt; getFieldWith (getArrayOf (getField "b")) "a"
--   </pre>
getArrayOf :: Decoder a -> Decoder [a]

-- | The underlying decoding monad that either returns a value of type
--   <tt>a</tt> or returns an error.
data DecodeM a

-- | Manually implement a <a>Decoder</a> with the given function.
makeDecoder :: (Value -> DecodeM a) -> Decoder a

-- | Run a <a>Decoder</a> with the given <a>Value</a>.
--   
--   <pre>
--   makeDecoder $ \v -&gt; do
--     a &lt;- runDecoder decoder1 v
--     b &lt;- runDecoder decoder2 v
--     return (a, b)
--   </pre>
--   
--   Satisfies
--   
--   <pre>
--   makeDecoder . runDecoder === id
--   runDecoder . makeDecoder === id
--   </pre>
runDecoder :: Decoder a -> Value -> DecodeM a

-- | Throw an error indicating that the given <a>Value</a> is invalid.
--   
--   <pre>
--   makeDecoder $ \v -&gt;
--     case v of
--       Integer 42 -&gt; invalidValue "We don't like this number" v
--       _ -&gt; runDecoder tomlDecoder v
--   
--   -- or alternatively,
--   tomlDecoder &gt;&gt;= case
--     42 -&gt; makeDecoder $ invalidValue "We don't like this number"
--     v -&gt; pure v
--   </pre>
invalidValue :: Text -> Value -> DecodeM a

-- | Throw an error indicating that the given <a>Value</a> isn't the
--   correct type of value.
--   
--   <pre>
--   makeDecoder $ \v -&gt;
--     case v of
--       String s -&gt; ...
--       _ -&gt; typeMismatch v
--   </pre>
typeMismatch :: Value -> DecodeM a

-- | Throw a generic failure message.
decodeFail :: Text -> DecodeM a
data Value
Table :: Table -> Value
Array :: [Value] -> Value
String :: Text -> Value
Integer :: Integer -> Value
Float :: Double -> Value
Boolean :: Bool -> Value
OffsetDateTime :: (LocalTime, TimeZone) -> Value
LocalDateTime :: LocalTime -> Value
LocalDate :: Day -> Value
LocalTime :: TimeOfDay -> Value

-- | Render a Value in pseudo-JSON format.
renderValue :: Value -> Text
type Table = Map Text Value
data TOMLError
ParseError :: Text -> TOMLError
NormalizeError :: NormalizeError -> TOMLError
DecodeError :: DecodeContext -> DecodeError -> TOMLError
data NormalizeError

-- | When a key is defined twice, e.g.
--   
--   <pre>
--   name = <tt>First</tt>
--   name = <tt>Second</tt>
--   </pre>
DuplicateKeyError :: NonEmpty Text -> Value -> Value -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_existingValue] :: NormalizeError -> Value
[_valueToSet] :: NormalizeError -> Value

-- | When a section is defined twice, e.g.
--   
--   <pre>
--   [foo]
--   a = 1
--   
--   [foo]
--   b = 2
--   </pre>
DuplicateSectionError :: NonEmpty Text -> NormalizeError
[_sectionKey] :: NormalizeError -> NonEmpty Text

-- | When a key attempts to extend an invalid table
--   
--   <pre>
--   a = {}
--   [a.b]
--   
--   b = {}
--   b.a = 1
--   
--   c.x.x = 1
--   [c.a]
--   </pre>
ExtendTableError :: NonEmpty Text -> NonEmpty Text -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_originalKey] :: NormalizeError -> NonEmpty Text

-- | When a section attempts to extend a table within an inline array
--   
--   <pre>
--   a = [{ b = 1 }]
--   [a.c]
--   </pre>
ExtendTableInInlineArrayError :: NonEmpty Text -> NonEmpty Text -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_originalKey] :: NormalizeError -> NonEmpty Text

-- | When a key is already defined, but attempting to create an implicit
--   array at the same key, e.g.
--   
--   <pre>
--   list = [1, 2, 3]
--   
--   [[list]]
--   a = 1
--   </pre>
ImplicitArrayForDefinedKeyError :: NonEmpty Text -> Value -> Table -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_existingValue] :: NormalizeError -> Value
[_tableSection] :: NormalizeError -> Table

-- | When a non-table value is already defined in a nested key, e.g.
--   
--   <pre>
--   a.b = 1
--   a.b.c.d = 2
--   </pre>
NonTableInNestedKeyError :: NonEmpty Text -> Value -> NonEmpty Text -> Value -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_existingValue] :: NormalizeError -> Value
[_originalKey] :: NormalizeError -> NonEmpty Text
[_originalValue] :: NormalizeError -> Value

-- | When a non-table value is already defined in a nested implicit array,
--   e.g.
--   
--   <pre>
--   a.b = 1
--   
--   [[a.b.c]]
--   d = 2
--   </pre>
NonTableInNestedImplicitArrayError :: NonEmpty Text -> Value -> NonEmpty Text -> Table -> NormalizeError
[_path] :: NormalizeError -> NonEmpty Text
[_existingValue] :: NormalizeError -> Value
[_sectionKey] :: NormalizeError -> NonEmpty Text
[_tableSection] :: NormalizeError -> Table
type DecodeContext = [ContextItem]
data ContextItem
Key :: Text -> ContextItem
Index :: Int -> ContextItem
data DecodeError
MissingField :: DecodeError
InvalidValue :: Text -> Value -> DecodeError
TypeMismatch :: Value -> DecodeError
OtherDecodeError :: Text -> DecodeError
renderTOMLError :: TOMLError -> Text
