Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Store inline-tag along with the tables #330

Open
vrom911 opened this issue Jun 22, 2020 · 1 comment
Open

[RFC] Store inline-tag along with the tables #330

vrom911 opened this issue Jun 22, 2020 · 1 comment
Labels
ast Type of TOML question Further information is requested

Comments

@vrom911
Copy link
Member

vrom911 commented Jun 22, 2020

There are two ways to write tables in TOML.
But currently tomland doesn't keep track of such information, though it could be useful during pretty-printing later. This info is not that hard to get, as we already parsing both cases.

The question is, do you think that it worth to support this enhancement? And what the downsides are?

@vrom911 vrom911 added question Further information is requested ast Type of TOML labels Jun 22, 2020
@chshersh
Copy link
Contributor

@vrom911 Excellent idea 👌 It's totally possible because we already know this information during parsing. I think, the solution to this problem will be to implement a type like:

data TomlTable = TomlTable
    { tomlTableInline :: TableInline
    , tomlTableTOML :: TOML
    }

And instead of the current type

data TOML = TOML
{ tomlPairs :: !(HashMap Key AnyValue)
, tomlTables :: !(PrefixMap TOML)
, tomlTableArrays :: !(HashMap Key (NonEmpty TOML))
} deriving stock (Show, Eq, Generic)

it will look like this

data TOML = TOML
    { tomlPairs       :: !(HashMap Key AnyValue)
    , tomlTables      :: !(PrefixMap TomlTable)
    , tomlTableArrays :: !(HashMap Key (NonEmpty TomlTable))
    }

I think it's totally worth it, since it will help to produce better output!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast Type of TOML question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants