kowainik / tomland

🏝 Bidirectional TOML serialization
https://kowainik.github.io/posts/2019-01-14-tomland
Mozilla Public License 2.0
120 stars 39 forks source link

PrintOptions for lists #325

Closed vrom911 closed 3 years ago

vrom911 commented 4 years ago

Bool to indicate whether to print list elements each on a separate line or all together (current version)

See use-case: https://github.com/kowainik/life-sync/pull/102#discussion_r428633721

willbasky commented 3 years ago

@vrom911 Hi! Could you clarify what list the task related ? I mean how what type in tomland and how it will look like with and without flag in toml file?

vrom911 commented 3 years ago

@willbasky , sure! I was thinking of patching the PrintOptions data type: https://github.com/kowainik/tomland/blob/080e6720e6d0740f139408fa73e2d861e1d6c57b/src/Toml/Type/Printer.hs#L45-L57

by adding an additional field in there. That field should indicate how to pretty-print list types. Now, it would print all array elements in one line:

https://github.com/kowainik/tomland/blob/080e6720e6d0740f139408fa73e2d861e1d6c57b/src/Toml/Type/Printer.hs#L146

But with this change, lists should be outputted either like this:

foo = 
    [ a
    , b
    ]

or as before:

foo = [a, b]