-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | TOML 1.0.0 parser -- -- TOML parser using generated lexers and parsers with careful attention -- to the TOML 1.0.0 semantics for defining tables. @package toml-parser @version 1.2.0.0 -- | This module provides the datatype for the lexical syntax of TOML -- files. These tokens are generated by Toml.Lexer and consumed in -- Toml.Parser. module Toml.Lexer.Token -- | Lexical token data Token -- |
--   true
--   
TokTrue :: Token -- |
--   false
--   
TokFalse :: Token -- |
--   ','
--   
TokComma :: Token -- |
--   '='
--   
TokEquals :: Token -- |
--   '\n'
--   
TokNewline :: Token -- |
--   .
--   
TokPeriod :: Token -- |
--   '['
--   
TokSquareO :: Token -- |
--   ']'
--   
TokSquareC :: Token -- |
--   '[['
--   
Tok2SquareO :: Token -- |
--   ']]'
--   
Tok2SquareC :: Token -- |
--   '{'
--   
TokCurlyO :: Token -- |
--   '}'
--   
TokCurlyC :: Token -- | bare key TokBareKey :: String -> Token -- | string literal TokString :: String -> Token -- | multiline string literal TokMlString :: String -> 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 -- | lexical error TokError :: String -> Token -- | end of file TokEOF :: Token -- | Construct a TokString from a literal string lexeme. mkLiteralString :: String -> Token -- | Construct a TokMlString from a literal multi-line string -- lexeme. mkMlLiteralString :: String -> Token -- | Construct a TokInteger from a binary integer literal lexeme. mkBinInteger :: String -> Token -- | Construct a TokInteger from a decimal integer literal lexeme. mkDecInteger :: String -> Token -- | Construct a TokInteger from a octal integer literal lexeme. mkOctInteger :: String -> Token -- | Construct a TokInteger from a hexadecimal integer literal -- lexeme. mkHexInteger :: String -> Token -- | Construct a TokFloat 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] -- | Make a TokError from a lexical error message. mkError :: String -> Token instance GHC.Show.Show Toml.Lexer.Token.Token instance GHC.Read.Read Toml.Lexer.Token.Token -- | This module provides the Position type for tracking locations -- in files while doing lexing and parsing for providing more useful -- error messages. module Toml.Position -- | A position in a text file data Position Position :: {-# UNPACK #-} !Int -> Position [posIndex, posLine, posColumn] :: Position -> {-# UNPACK #-} !Int -- | The initial Position 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.Position.Position instance GHC.Classes.Ord Toml.Position.Position instance GHC.Show.Show Toml.Position.Position instance GHC.Read.Read Toml.Position.Position -- | This module provides a simple tuple for tracking pairs of values and -- their file locations. module Toml.Located -- | A value annotated with its text file position data Located a Located :: {-# UNPACK #-} !Position -> !a -> Located a [locPosition] :: Located a -> {-# UNPACK #-} !Position [locThing] :: Located a -> !a instance Data.Traversable.Traversable Toml.Located.Located instance Data.Foldable.Foldable Toml.Located.Located instance GHC.Base.Functor Toml.Located.Located instance GHC.Show.Show a => GHC.Show.Show (Toml.Located.Located a) instance GHC.Read.Read a => GHC.Read.Read (Toml.Located.Located a) -- | 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.Parser.Types -- | Non-empty sequence of dotted simple keys type Key = NonEmpty (Located String) -- | Headers and assignments corresponding to lines of a TOML file data Expr -- | key value assignment: key = value KeyValExpr :: Key -> Val -> Expr -- | table: [key] TableExpr :: Key -> Expr -- | array of tables: [[key]] ArrayTableExpr :: Key -> Expr -- | Unvalidated TOML values. Table are represented as a list of -- assignments rather than as resolved maps. data Val ValInteger :: Integer -> Val ValFloat :: Double -> Val ValArray :: [Val] -> Val ValTable :: [(Key, Val)] -> Val ValBool :: Bool -> Val ValString :: String -> Val ValTimeOfDay :: TimeOfDay -> Val ValZonedTime :: ZonedTime -> Val ValLocalTime :: LocalTime -> Val ValDay :: Day -> Val -- | Kinds of table headers. data SectionKind -- | TableKind :: SectionKind -- | ArrayTableKind :: SectionKind instance GHC.Show.Show Toml.Parser.Types.Val instance GHC.Read.Read Toml.Parser.Types.Val instance GHC.Show.Show Toml.Parser.Types.Expr instance GHC.Read.Read Toml.Parser.Types.Expr instance GHC.Classes.Eq Toml.Parser.Types.SectionKind instance GHC.Show.Show Toml.Parser.Types.SectionKind instance GHC.Read.Read Toml.Parser.Types.SectionKind -- | This module provides a custom engine for the Alex generated lexer. -- This lexer drive provides nested states, unicode support, and file -- location tracking. -- -- The various states of this module are needed to deal with the varying -- lexing rules while lexing values, keys, and string-literals. module Toml.Lexer.Utils -- | Type of actions associated with lexer patterns type Action = Located String -> State [Context] [Located Token] -- | Representation of the current lexer state. data Context -- | processing an inline list, lex values ListContext :: Position -> Context -- | processing an inline table, don't lex values TableContext :: Position -> Context -- | processing after an equals, lex one value ValueContext :: Context -- | position of opening delimiter and list of fragments MlStrContext :: Position -> [String] -> Context -- | position of opening delimiter and list of fragments StrContext :: Position -> [String] -> Context -- | Pop the first character off a located string if it's not empty. The -- resulting Int will either be the ASCII value of the character -- or 1 for non-ASCII Unicode values. To avoid a clash, -- x1 is remapped to 0. locatedUncons :: Located String -> Maybe (Int, Located String) -- | Emit a value token using the current lexeme and update the current -- state value :: (String -> Token) -> Action -- | Emit a value token and update the current state value_ :: Token -> Action -- | Emit a token using the current lexeme token :: (String -> Token) -> Action -- | Emit a token ignoring the current lexeme token_ :: Token -> Action -- | Record an opening square bracket and update the state squareO :: Action -- | Record a closing square bracket and update the state squareC :: Action -- | Record an opening curly bracket and update the state curlyO :: Action -- | Record a closing curly bracket and update the state curlyC :: Action -- | Record an = token and update the state equals :: Action -- | Attempt to parse the current lexeme as a date-time token. timeValue :: ParseTime a => String -> [String] -> (a -> Token) -> Action -- | Generate the correct terminating token given the current lexer state. eofToken :: [Context] -> Located String -> Located Token -- | Add a literal fragment of a string to the current string state. strFrag :: Action -- | Start a multi-line basic string literal startMlStr :: Action -- | Start a basic string literal startStr :: Action -- | End the current string state and emit the string literal token. endStr :: Action -- | Resolve a unicode escape sequence and add it to the current string -- literal unicodeEscape :: Action instance GHC.Show.Show Toml.Lexer.Utils.Context -- | 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 -- LexerUtils. module Toml.Lexer -- | Generate a lazy-list of tokens from the input string. The token stream -- is guaranteed to be terminated either with TokEOF or -- TokError. scanTokens :: String -> [Located Token] -- | Lex a single token in a value context. This is mostly useful for -- testing. lexValue :: String -> Token -- | Lexical token data Token -- |
--   true
--   
TokTrue :: Token -- |
--   false
--   
TokFalse :: Token -- |
--   ','
--   
TokComma :: Token -- |
--   '='
--   
TokEquals :: Token -- |
--   '\n'
--   
TokNewline :: Token -- |
--   .
--   
TokPeriod :: Token -- |
--   '['
--   
TokSquareO :: Token -- |
--   ']'
--   
TokSquareC :: Token -- |
--   '[['
--   
Tok2SquareO :: Token -- |
--   ']]'
--   
Tok2SquareC :: Token -- |
--   '{'
--   
TokCurlyO :: Token -- |
--   '}'
--   
TokCurlyC :: Token -- | bare key TokBareKey :: String -> Token -- | string literal TokString :: String -> Token -- | multiline string literal TokMlString :: String -> 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 -- | lexical error TokError :: String -> Token -- | end of file TokEOF :: Token -- | This module parses TOML tokens into a list of raw, uninterpreted -- sections and assignments. module Toml.Parser -- | Headers and assignments corresponding to lines of a TOML file data Expr -- | key value assignment: key = value KeyValExpr :: Key -> Val -> Expr -- | table: [key] TableExpr :: Key -> Expr -- | array of tables: [[key]] ArrayTableExpr :: Key -> Expr -- | Kinds of table headers. data SectionKind -- | TableKind :: SectionKind -- | ArrayTableKind :: SectionKind -- | Unvalidated TOML values. Table are represented as a list of -- assignments rather than as resolved maps. data Val ValInteger :: Integer -> Val ValFloat :: Double -> Val ValArray :: [Val] -> Val ValTable :: [(Key, Val)] -> Val ValBool :: Bool -> Val ValString :: String -> Val ValTimeOfDay :: TimeOfDay -> Val ValZonedTime :: ZonedTime -> Val ValLocalTime :: LocalTime -> Val ValDay :: Day -> Val -- | Non-empty sequence of dotted simple keys type Key = NonEmpty (Located String) -- | 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 -- Toml.Semantics. parseRawToml :: [Located Token] -> Either (Located Token) [Expr] -- | 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. module Toml.Value -- | Semantic TOML value with all table assignments resolved. data Value Integer :: Integer -> Value Float :: Double -> Value Array :: [Value] -> Value Table :: Table -> Value Bool :: Bool -> Value String :: String -> Value TimeOfDay :: TimeOfDay -> Value ZonedTime :: ZonedTime -> Value LocalTime :: LocalTime -> Value Day :: Day -> Value -- | Representation of a TOML key-value table. type Table = Map String Value instance GHC.Generics.Generic Toml.Value.Value instance Data.Data.Data Toml.Value.Value instance GHC.Read.Read Toml.Value.Value instance GHC.Show.Show Toml.Value.Value instance GHC.Classes.Eq Toml.Value.Value -- | The ToValue class provides a conversion function from -- application-specific to TOML values. -- -- Because the top-level TOML document is always a table, the -- ToTable class is for types that specifically support conversion -- from a Table. -- -- Toml.ToValue.Generic can be used to derive instances of -- ToTable automatically for record types. module Toml.ToValue -- | Class for types that can be embedded into Value 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 embed into a Table and then the -- ToValue instance can be derived with -- defaultTableToValue. class ToValue a => ToTable a -- | Convert a single value into a table toTable :: ToTable a => a -> Table -- | Convenience function for building ToValue instances. defaultTableToValue :: ToTable a => a -> Value -- | Build a Table from a list of key-value pairs. -- -- Use .= for a convenient way to build the pairs. table :: [(String, Value)] -> Value -- | Convenience function for building key-value pairs while constructing a -- Table. -- --
--   table [a .= b, c .= d]
--   
(.=) :: ToValue a => String -> a -> (String, Value) instance (k GHC.Types.~ GHC.Base.String, Toml.ToValue.ToValue v) => Toml.ToValue.ToTable (Data.Map.Internal.Map k v) instance (k GHC.Types.~ GHC.Base.String, Toml.ToValue.ToValue v) => Toml.ToValue.ToValue (Data.Map.Internal.Map k v) instance Toml.ToValue.ToValue Toml.Value.Value instance Toml.ToValue.ToValue GHC.Types.Char instance Toml.ToValue.ToValue a => Toml.ToValue.ToValue [a] instance Toml.ToValue.ToValue GHC.Types.Double instance Toml.ToValue.ToValue GHC.Types.Float instance Toml.ToValue.ToValue GHC.Types.Bool instance Toml.ToValue.ToValue Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay instance Toml.ToValue.ToValue Data.Time.LocalTime.Internal.LocalTime.LocalTime instance Toml.ToValue.ToValue Data.Time.LocalTime.Internal.ZonedTime.ZonedTime instance Toml.ToValue.ToValue Data.Time.Calendar.Days.Day instance Toml.ToValue.ToValue GHC.Num.Integer.Integer instance Toml.ToValue.ToValue GHC.Num.Natural.Natural instance Toml.ToValue.ToValue GHC.Types.Int instance Toml.ToValue.ToValue GHC.Int.Int8 instance Toml.ToValue.ToValue GHC.Int.Int16 instance Toml.ToValue.ToValue GHC.Int.Int32 instance Toml.ToValue.ToValue GHC.Int.Int64 instance Toml.ToValue.ToValue GHC.Types.Word instance Toml.ToValue.ToValue GHC.Word.Word8 instance Toml.ToValue.ToValue GHC.Word.Word16 instance Toml.ToValue.ToValue GHC.Word.Word32 instance Toml.ToValue.ToValue GHC.Word.Word64 -- | Use genericToTable to derive an instance of ToTable -- using the field names of a record. module Toml.ToValue.Generic -- | Supports conversion of product types with field selector names to TOML -- values. class GToTable f gToTable :: GToTable f => f a -> Table -- | Use a record's field names to generate a Table genericToTable :: (Generic a, GToTable (Rep a)) => a -> Table instance Toml.ToValue.Generic.GToTable f => Toml.ToValue.Generic.GToTable (GHC.Generics.D1 c f) instance Toml.ToValue.Generic.GToTable f => Toml.ToValue.Generic.GToTable (GHC.Generics.C1 c f) instance (Toml.ToValue.Generic.GToTable f, Toml.ToValue.Generic.GToTable g) => Toml.ToValue.Generic.GToTable (f GHC.Generics.:*: g) instance (GHC.Generics.Selector s, Toml.ToValue.ToValue a) => Toml.ToValue.Generic.GToTable (GHC.Generics.S1 s (GHC.Generics.K1 i (GHC.Maybe.Maybe a))) instance (GHC.Generics.Selector s, Toml.ToValue.ToValue a) => Toml.ToValue.Generic.GToTable (GHC.Generics.S1 s (GHC.Generics.K1 i a)) instance Toml.ToValue.Generic.GToTable GHC.Generics.U1 instance Toml.ToValue.Generic.GToTable GHC.Generics.V1 -- | This module provides human-readable renderers for types used in this -- package to assist error message production. -- -- The generated Doc values are annotated with DocClass -- values to assist in producing syntax-highlighted outputs. -- -- To extract a plain String representation, use show. 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 [key] and [[key]] 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 appropriate. prettyToml :: Table -> TomlDoc -- | Render a value suitable for assignment on the right-hand side of an -- equals sign. This value will always occupy a single line. prettyValue :: Value -> TomlDoc -- | Render token for human-readable error messages. prettyToken :: Token -> String -- | Pretty-print a section heading. The result is annotated as a -- TableClass. prettySectionKind :: SectionKind -> NonEmpty String -> TomlDoc -- | Renders a simple-key using quotes where necessary. prettySimpleKey :: String -> Doc a -- | Renders a dotted-key using quotes where necessary and annotated as a -- KeyClass. prettyKey :: NonEmpty String -> TomlDoc instance GHC.Classes.Ord Toml.Pretty.DocClass instance GHC.Classes.Eq Toml.Pretty.DocClass instance GHC.Show.Show Toml.Pretty.DocClass instance GHC.Read.Read Toml.Pretty.DocClass -- | This module extracts the nested Map representation of a TOML file. It -- detects invalid key assignments and resolves dotted key assignments. module Toml.Semantics -- | Extract semantic value from sequence of raw TOML expressions or report -- an error string. semantics :: [Expr] -> Either String Table instance GHC.Show.Show Toml.Semantics.FrameKind instance GHC.Show.Show Toml.Semantics.Frame -- | 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. module Toml.FromValue.Matcher -- | Computations that result in a Result and which track a list of -- nested contexts to assist in generating warnings and error messages. -- -- Use withScope to run a Matcher in a new, nested scope. data Matcher 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 a Failure :: [String] -> Result a Success :: [String] -> a -> Result a -- | Run a Matcher with an empty scope. runMatcher :: Matcher a -> Result a -- | Run a Matcher with a locally extended scope. withScope :: String -> Matcher a -> Matcher a -- | Get the current list of scopes. getScope :: Matcher [String] -- | Emit a warning mentioning the current scope. warning :: String -> Matcher () -- | Update the scope with the message corresponding to a table key inKey :: String -> Matcher a -> Matcher a -- | Update the scope with the message corresponding to an array index inIndex :: Int -> Matcher a -> Matcher a instance GHC.Base.Monoid Toml.FromValue.Matcher.Strings instance GHC.Base.Semigroup Toml.FromValue.Matcher.Strings instance GHC.Base.MonadPlus Toml.FromValue.Matcher.Matcher instance GHC.Base.Alternative Toml.FromValue.Matcher.Matcher instance GHC.Base.Monad Toml.FromValue.Matcher.Matcher instance GHC.Base.Applicative Toml.FromValue.Matcher.Matcher instance GHC.Base.Functor Toml.FromValue.Matcher.Matcher instance GHC.Classes.Ord a => GHC.Classes.Ord (Toml.FromValue.Matcher.Result a) instance GHC.Classes.Eq a => GHC.Classes.Eq (Toml.FromValue.Matcher.Result a) instance GHC.Show.Show a => GHC.Show.Show (Toml.FromValue.Matcher.Result a) instance GHC.Read.Read a => GHC.Read.Read (Toml.FromValue.Matcher.Result a) instance Control.Monad.Fail.MonadFail Toml.FromValue.Matcher.Matcher -- | 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. -- -- This module provides the ParseTable implementation, but most of -- the basic functionality is exported directly from -- Toml.FromValue. module Toml.FromValue.ParseTable -- | A Matcher that tracks a current set of unmatched key-value -- pairs from a table. -- -- Use optKey and reqKey to extract keys. -- -- Use getTable and setTable to override the table and -- implement other primitives. data ParseTable a -- | Key and value matching function data KeyAlt a -- | pick alternative based on key match Key :: String -> (Value -> Matcher a) -> KeyAlt a -- | default case when no previous cases matched Else :: Matcher a -> KeyAlt 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 -- reqKey cases together with (<|>) -- because that will generate one error message for each unmatched -- alternative as well as the error associate with the matched -- alternative. pickKey :: [KeyAlt a] -> ParseTable a -- | Run a ParseTable computation with a given starting -- Table. Unused tables will generate a warning. To change this -- behavior getTable and setTable can be used to discard or -- generate error messages. runParseTable :: ParseTable a -> Table -> Matcher a -- | Lift a matcher into the current table parsing context. liftMatcher :: Matcher a -> ParseTable a -- | Emit a warning at the current location. warnTable :: String -> ParseTable () -- | Replace the remaining portion of the table being matched. setTable :: Table -> ParseTable () -- | Return the remaining portion of the table being matched. getTable :: ParseTable Table instance GHC.Base.MonadPlus Toml.FromValue.ParseTable.ParseTable instance GHC.Base.Alternative Toml.FromValue.ParseTable.ParseTable instance GHC.Base.Monad Toml.FromValue.ParseTable.ParseTable instance GHC.Base.Applicative Toml.FromValue.ParseTable.ParseTable instance GHC.Base.Functor Toml.FromValue.ParseTable.ParseTable instance Control.Monad.Fail.MonadFail Toml.FromValue.ParseTable.ParseTable -- | Use FromValue to define a transformation from some Value -- to an application domain type. -- -- Use ParseTable to help build FromValue 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 warning and warnTable -- (depending on what) context you're in. These warnings can provide -- useful feedback about problematic decodings or keys that might be -- unused now but were perhaps meaningful in an old version of a -- configuration file. -- -- Toml.FromValue.Generic can be used to derive instances of -- FromValue automatically for record types. module Toml.FromValue -- | Class for types that can be decoded from a TOML value. class FromValue a -- | Convert a Value or report an error message fromValue :: FromValue a => Value -> Matcher a -- | Used to implement instance for '[]'. Most implementations rely on the -- default implementation. listFromValue :: FromValue a => Value -> Matcher [a] -- | Computations that result in a Result and which track a list of -- nested contexts to assist in generating warnings and error messages. -- -- Use withScope to run a Matcher in a new, nested scope. data Matcher 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 a Failure :: [String] -> Result a Success :: [String] -> a -> Result a -- | Emit a warning mentioning the current scope. warning :: String -> Matcher () -- | A Matcher that tracks a current set of unmatched key-value -- pairs from a table. -- -- Use optKey and reqKey to extract keys. -- -- Use getTable and setTable to override the table and -- implement other primitives. data ParseTable a -- | Run a ParseTable computation with a given starting -- Table. Unused tables will generate a warning. To change this -- behavior getTable and setTable can be used to discard or -- generate error messages. runParseTable :: ParseTable a -> Table -> Matcher a -- | Used to derive a fromValue implementation from a -- ParseTable matcher. parseTableFromValue :: ParseTable a -> Value -> Matcher a -- | Match a table entry by key if it exists or return Nothing if -- not. optKey :: FromValue a => String -> ParseTable (Maybe a) -- | Match a table entry by key or report an error if missing. reqKey :: FromValue a => String -> ParseTable a -- | Emit a warning at the current location. warnTable :: String -> ParseTable () -- | Key and value matching function data KeyAlt a -- | pick alternative based on key match Key :: String -> (Value -> Matcher a) -> KeyAlt a -- | default case when no previous cases matched Else :: Matcher a -> KeyAlt 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 -- reqKey cases together with (<|>) -- because that will generate one error message for each unmatched -- alternative as well as the error associate with the matched -- alternative. pickKey :: [KeyAlt a] -> ParseTable a -- | Return the remaining portion of the table being matched. getTable :: ParseTable Table -- | Replace the remaining portion of the table being matched. setTable :: Table -> ParseTable () -- | Lift a matcher into the current table parsing context. liftMatcher :: Matcher a -> ParseTable a instance (GHC.Classes.Ord k, Data.String.IsString k, Toml.FromValue.FromValue v) => Toml.FromValue.FromValue (Data.Map.Internal.Map k v) instance Toml.FromValue.FromValue GHC.Num.Integer.Integer instance Toml.FromValue.FromValue GHC.Num.Natural.Natural instance Toml.FromValue.FromValue GHC.Types.Int instance Toml.FromValue.FromValue GHC.Int.Int8 instance Toml.FromValue.FromValue GHC.Int.Int16 instance Toml.FromValue.FromValue GHC.Int.Int32 instance Toml.FromValue.FromValue GHC.Int.Int64 instance Toml.FromValue.FromValue GHC.Types.Word instance Toml.FromValue.FromValue GHC.Word.Word8 instance Toml.FromValue.FromValue GHC.Word.Word16 instance Toml.FromValue.FromValue GHC.Word.Word32 instance Toml.FromValue.FromValue GHC.Word.Word64 instance Toml.FromValue.FromValue GHC.Types.Char instance Toml.FromValue.FromValue GHC.Types.Double instance Toml.FromValue.FromValue GHC.Types.Float instance Toml.FromValue.FromValue GHC.Types.Bool instance Toml.FromValue.FromValue a => Toml.FromValue.FromValue [a] instance Toml.FromValue.FromValue Data.Time.Calendar.Days.Day instance Toml.FromValue.FromValue Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay instance Toml.FromValue.FromValue Data.Time.LocalTime.Internal.ZonedTime.ZonedTime instance Toml.FromValue.FromValue Data.Time.LocalTime.Internal.LocalTime.LocalTime instance Toml.FromValue.FromValue Toml.Value.Value -- | Use genericParseTable to derive a ParseTable using the -- field names of a record. This can be combined with -- parseTableFromValue to derive a FromValue instance. module Toml.FromValue.Generic -- | Supports conversion of product types with field selector names to TOML -- values. class GParseTable f -- | Convert a value and apply the continuation to the result. gParseTable :: GParseTable f => (f a -> ParseTable b) -> ParseTable b -- | Match a Table using the field names in a record. genericParseTable :: (Generic a, GParseTable (Rep a)) => ParseTable a instance Toml.FromValue.Generic.GParseTable f => Toml.FromValue.Generic.GParseTable (GHC.Generics.D1 c f) instance Toml.FromValue.Generic.GParseTable f => Toml.FromValue.Generic.GParseTable (GHC.Generics.C1 c f) instance (Toml.FromValue.Generic.GParseTable f, Toml.FromValue.Generic.GParseTable g) => Toml.FromValue.Generic.GParseTable (f GHC.Generics.:*: g) instance (GHC.Generics.Selector s, Toml.FromValue.FromValue a) => Toml.FromValue.Generic.GParseTable (GHC.Generics.S1 s (GHC.Generics.K1 i (GHC.Maybe.Maybe a))) instance (GHC.Generics.Selector s, Toml.FromValue.FromValue a) => Toml.FromValue.Generic.GParseTable (GHC.Generics.S1 s (GHC.Generics.K1 i a)) instance Toml.FromValue.Generic.GParseTable GHC.Generics.U1 -- | This is the high-level interface to the toml-parser library. It -- enables parsing, printing, and coversion into and out of -- application-specific representations. -- -- This parser implements TOML 1.0.0 https://toml.io/en/v1.0.0 as -- carefully as possible. module Toml -- | Representation of a TOML key-value table. type Table = Map String Value -- | Semantic TOML value with all table assignments resolved. data Value Integer :: Integer -> Value Float :: Double -> Value Array :: [Value] -> Value Table :: Table -> Value Bool :: Bool -> Value String :: String -> Value TimeOfDay :: TimeOfDay -> Value ZonedTime :: ZonedTime -> Value LocalTime :: LocalTime -> Value Day :: Day -> Value -- | Parse a TOML formatted Value or report an error message. parse :: String -> Either String Table -- | Render a complete TOML document using top-level table and array of -- table sections where appropriate. prettyToml :: Table -> TomlDoc -- | Annotation used to enable styling pretty-printed TOML data DocClass -- | top-level [key] and [[key]] 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 -- | Use the FromValue instance to decode a value from a TOML -- string. decode :: FromValue a => String -> Result a -- | Use the ToTable instance to encode a value to a TOML string. encode :: ToTable a => a -> TomlDoc -- | 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 a Failure :: [String] -> Result a Success :: [String] -> a -> Result a