Copyright | (c) Eric Mertens 2023 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 =parseRawToml
txt to =extractTableOrder
exprs Right toml =semantics
exprs projection =projectKey
toprettyTomlOrdered
projection toml)
Since: 1.3.1.0
Synopsis
- data TableOrder
- extractTableOrder :: [Expr] -> TableOrder
- projectKey :: TableOrder -> [String] -> String -> ProjectedKey
- data ProjectedKey
- debugTableOrder :: TableOrder -> String
Documentation
data TableOrder Source #
Summary of the order of the keys in a TOML document.
extractTableOrder :: [Expr] -> TableOrder Source #
Extract a TableOrder
from the output of parseRawToml
to be later used with projectKey
.
:: TableOrder | table order |
-> [String] | table path |
-> String | key |
-> ProjectedKey | type suitable for ordering table keys |
Generate a projection function for use with prettyTomlOrdered
data ProjectedKey Source #
Instances
Eq ProjectedKey Source # | |
Defined in Toml.Semantics.Ordered (==) :: ProjectedKey -> ProjectedKey -> Bool # (/=) :: ProjectedKey -> ProjectedKey -> Bool # | |
Ord ProjectedKey Source # | |
Defined in Toml.Semantics.Ordered compare :: ProjectedKey -> ProjectedKey -> Ordering # (<) :: ProjectedKey -> ProjectedKey -> Bool # (<=) :: ProjectedKey -> ProjectedKey -> Bool # (>) :: ProjectedKey -> ProjectedKey -> Bool # (>=) :: ProjectedKey -> ProjectedKey -> Bool # max :: ProjectedKey -> ProjectedKey -> ProjectedKey # min :: ProjectedKey -> ProjectedKey -> ProjectedKey # |
debugTableOrder :: TableOrder -> String Source #
Render a white-space nested representation of the key ordering extracted
by extractTableOrder
. This is provided for debugging and understandability.