-- 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.0.0.0 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 -- | 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 () -- | Computation outcome with error and warning messages. data Result a Failure :: String -> Result a Success :: [String] -> a -> Result a 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 the datatype for the lexical syntax of TOML -- files. These tokens will drive the parser in the Parser module. 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 basic string lexeme. mkBasicString :: String -> Token -- | Construct a TokString from a literal string lexeme. mkLiteralString :: String -> Token -- | Construct a TokMlString from a basic multi-line string lexeme. mkMlBasicString :: 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 -- |
-- 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 -- |
-- table [a .= b, c .= d] --(.=) :: ToValue a => String -> a -> (String, Value) 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 -- | This module provides human-readable renderers for types used in this -- package to assist error message production. 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 -- | Use FromValue to define a transformation from some Value -- to an application domain type. -- -- Use FromTable to define transformations specifically from -- Table. These instances are interesting because all top-level -- TOML values are tables, so these are the types that work for top-level -- deserialization. -- -- Use ParseTable to help build FromTable instances. 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. 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] -- | Class for types that can be decoded from a TOML table. class FromValue a => FromTable a -- | Convert a Table or report an error message fromTable :: FromTable a => Table -> Matcher a -- | Derive fromValue implementation from fromTable defaultTableFromValue :: FromTable 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 -- | 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 -- | Emit a warning mentioning the current scope. warning :: String -> Matcher () -- | Computation outcome with error and warning messages. data Result a Failure :: String -> Result a Success :: [String] -> a -> Result a -- | A Matcher that tracks a current set of unmatched key-value -- pairs from a table. -- -- Use optKey, reqKey, 'rej 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 -- | 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 () -- | Return the remaining portion of the table being matched. getTable :: ParseTable Table -- | Replace the remaining portion of the table being matched. setTable :: Table -> ParseTable () instance GHC.Base.Monad Toml.FromValue.ParseTable instance GHC.Base.Applicative Toml.FromValue.ParseTable instance GHC.Base.Functor Toml.FromValue.ParseTable instance Control.Monad.Fail.MonadFail Toml.FromValue.ParseTable instance (GHC.Classes.Ord k, Data.String.IsString k, Toml.FromValue.FromValue v) => Toml.FromValue.FromTable (Data.Map.Internal.Map k v) 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 -- | This module parses TOML into semantically meaningful values. -- -- 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 FromTable instance to decode a value from a TOML -- string. decode :: FromTable 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. data Result a Failure :: String -> Result a Success :: [String] -> a -> Result a