    {-|
    Module      : Toml.Syntax.Types
    Description : Raw expressions from a parsed TOML file
    Copyright   : (c) Eric Mertens, 2023
    License     : ISC
    Maintainer  : emertens@gmail.com

    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 "Semantics" module.

    -}
    module Toml.Syntax.Types (
        Key,
        Expr(..),
        Val(..),
        SectionKind(..),
        ) where

    import Data.List.NonEmpty (NonEmpty)
    import Data.Text (Text)
    import Data.Time (Day, LocalTime, TimeOfDay, ZonedTime)

    -- | 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
        = KeyValExpr     (Key a) (Val a) -- ^ key value assignment: @key = value@
        | TableExpr      (Key a)         -- ^ table: @[key]@
        | ArrayTableExpr (Key a)         -- ^ array of tables: @[[key]]@
        deriving (ReadPrec [Expr a]
    ReadPrec (Expr a)
    Int -> ReadS (Expr a)
    ReadS [Expr a]
    (Int -> ReadS (Expr a))
    -> ReadS [Expr a]
    -> ReadPrec (Expr a)
    -> ReadPrec [Expr a]
    -> Read (Expr a)
    forall a. Read a => ReadPrec [Expr a]
    forall a. Read a => ReadPrec (Expr a)
    forall a. Read a => Int -> ReadS (Expr a)
    forall a. Read a => ReadS [Expr a]
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: forall a. Read a => Int -> ReadS (Expr a)
    readsPrec :: Int -> ReadS (Expr a)
    $creadList :: forall a. Read a => ReadS [Expr a]
    readList :: ReadS [Expr a]
    $creadPrec :: forall a. Read a => ReadPrec (Expr a)
    readPrec :: ReadPrec (Expr a)
    $creadListPrec :: forall a. Read a => ReadPrec [Expr a]
    readListPrec :: ReadPrec [Expr a]
    Read, Int -> Expr a -> ShowS
    [Expr a] -> ShowS
    Expr a -> String
    (Int -> Expr a -> ShowS)
    -> (Expr a -> String) -> ([Expr a] -> ShowS) -> Show (Expr a)
    forall a. Show a => Int -> Expr a -> ShowS
    forall a. Show a => [Expr a] -> ShowS
    forall a. Show a => Expr a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall a. Show a => Int -> Expr a -> ShowS
    showsPrec :: Int -> Expr a -> ShowS
    $cshow :: forall a. Show a => Expr a -> String
    show :: Expr a -> String
    $cshowList :: forall a. Show a => [Expr a] -> ShowS
    showList :: [Expr a] -> ShowS
    Show)

    -- | Unvalidated TOML values. Table are represented as a list of
    -- assignments rather than as resolved maps.
    data Val a
        = ValInteger   a Integer
        | ValFloat     a Double
        | ValArray     a [Val a]
        | ValTable     a [(Key a, Val a)]
        | ValBool      a Bool
        | ValString    a Text
        | ValTimeOfDay a TimeOfDay
        | ValZonedTime a ZonedTime
        | ValLocalTime a LocalTime
        | ValDay       a Day
        deriving (ReadPrec [Val a]
    ReadPrec (Val a)
    Int -> ReadS (Val a)
    ReadS [Val a]
    (Int -> ReadS (Val a))
    -> ReadS [Val a]
    -> ReadPrec (Val a)
    -> ReadPrec [Val a]
    -> Read (Val a)
    forall a. Read a => ReadPrec [Val a]
    forall a. Read a => ReadPrec (Val a)
    forall a. Read a => Int -> ReadS (Val a)
    forall a. Read a => ReadS [Val a]
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: forall a. Read a => Int -> ReadS (Val a)
    readsPrec :: Int -> ReadS (Val a)
    $creadList :: forall a. Read a => ReadS [Val a]
    readList :: ReadS [Val a]
    $creadPrec :: forall a. Read a => ReadPrec (Val a)
    readPrec :: ReadPrec (Val a)
    $creadListPrec :: forall a. Read a => ReadPrec [Val a]
    readListPrec :: ReadPrec [Val a]
    Read, Int -> Val a -> ShowS
    [Val a] -> ShowS
    Val a -> String
    (Int -> Val a -> ShowS)
    -> (Val a -> String) -> ([Val a] -> ShowS) -> Show (Val a)
    forall a. Show a => Int -> Val a -> ShowS
    forall a. Show a => [Val a] -> ShowS
    forall a. Show a => Val a -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall a. Show a => Int -> Val a -> ShowS
    showsPrec :: Int -> Val a -> ShowS
    $cshow :: forall a. Show a => Val a -> String
    show :: Val a -> String
    $cshowList :: forall a. Show a => [Val a] -> ShowS
    showList :: [Val a] -> ShowS
    Show)

    -- | Kinds of table headers
    data SectionKind
        = TableKind -- ^ [table]
        | ArrayTableKind -- ^ [[array of tables]]
        deriving (ReadPrec [SectionKind]
    ReadPrec SectionKind
    Int -> ReadS SectionKind
    ReadS [SectionKind]
    (Int -> ReadS SectionKind)
    -> ReadS [SectionKind]
    -> ReadPrec SectionKind
    -> ReadPrec [SectionKind]
    -> Read SectionKind
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS SectionKind
    readsPrec :: Int -> ReadS SectionKind
    $creadList :: ReadS [SectionKind]
    readList :: ReadS [SectionKind]
    $creadPrec :: ReadPrec SectionKind
    readPrec :: ReadPrec SectionKind
    $creadListPrec :: ReadPrec [SectionKind]
    readListPrec :: ReadPrec [SectionKind]
    Read, Int -> SectionKind -> ShowS
    [SectionKind] -> ShowS
    SectionKind -> String
    (Int -> SectionKind -> ShowS)
    -> (SectionKind -> String)
    -> ([SectionKind] -> ShowS)
    -> Show SectionKind
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> SectionKind -> ShowS
    showsPrec :: Int -> SectionKind -> ShowS
    $cshow :: SectionKind -> String
    show :: SectionKind -> String
    $cshowList :: [SectionKind] -> ShowS
    showList :: [SectionKind] -> ShowS
    Show, SectionKind -> SectionKind -> Bool
    (SectionKind -> SectionKind -> Bool)
    -> (SectionKind -> SectionKind -> Bool) -> Eq SectionKind
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: SectionKind -> SectionKind -> Bool
    == :: SectionKind -> SectionKind -> Bool
    $c/= :: SectionKind -> SectionKind -> Bool
    /= :: SectionKind -> SectionKind -> Bool
    Eq)