Summary of the order of the keys in a TOML document.
Moduletoml-parser-2.0.0.0Haskell2010
Toml.Semantics.Ordered
This module can help build a key ordering projection given an existing TOML file. This could be useful for applying a transformation to a TOML file before pretty-printing it back in something very close to the original order.
When using the computed order, table keys will be remembered in the order they appeared in the source file. Any key additional keys added to the tables will be ordered alphabetically after all the known keys.
demo =
do txt <- readFile "demo.toml"
let Right exprs = Toml.Parser.parseRawToml txt
to = extractTableOrder exprs
Right toml = semantics exprs
projection = projectKey to
print (prettyTomlOrdered projection toml)
- 2 types
- 3 values
- Packagetoml-parser-2.0.0.0
- Exports5
- LanguageHaskell2010
- LicenceISC
- SourceOrdered.hs
Extract a TableOrder from the output of Toml.Parser.parseRawToml
to be later used with projectKey.
projectKey :: TableOrdertable order
-> [Text]table path
-> Textkey
-> ProjectedKeytype suitable for ordering table keys
Generate a projection function for use with prettyTomlOrdered
Opaque type used by projectKey
Instances2Eq, Ord
Eq ProjectedKeyDefined in toml-parser-2.0.0.0 · Toml.Semantics.OrderedOrd ProjectedKeyDefined in toml-parser-2.0.0.0 · Toml.Semantics.Ordered
Render a white-space nested representation of the key ordering extracted by extractTableOrder. This is provided for debugging and understandability.