toml package:toml-parser

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.0.0 https://toml.io/en/v1.0.0 as carefully as possible. Use Toml.Schema to implement functions mapping between TOML values and your application types. Use Toml.Syntax and Toml.Semantics 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.
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.
Pretty-printer document with TOML class attributes to aid in syntax-highlighting.
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 prettyTomlOrdered.
Render a complete TOML document like prettyToml 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 [package] section first before any of the ancillary configuration sections. The table path is the name of the table being sorted. This allows the projection to be aware of which table is being sorted. The key 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 package section first, the secondary section second, and then all remaining cases are sorted alphabetically afterward.
example :: [String] -> String -> Either Int String
example [] "package" = Left 1
example [] "second"  = Left 2
example _  other     = Right other
We could also put the tables in reverse-alphabetical order by leveraging an existing newtype.
reverseOrderProj :: [String] -> String -> Down String
reverseOrderProj _ = Down
Helper type to use GHC's DerivingVia extension to derive ToValue, ToTable, FromValue for any product type.
Helper type to use GHC's DerivingVia extension to derive ToValue, ToTable, FromValue for records.
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.