We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Map Text X
I've been trying to figure out how I can go about parsing something like following:
[server.a.metadata] port = 1000 [server.b] backoff = 1 [server.b.metadata] port = 2000
In this,
server.*.metadata
a
b
c
prod
staging
I would like to parse it into following structure,
data ServerMetadata = ServerMetadata { port :: Int, backoff :: Maybe Int } type Servers = Map Text ServerMetadata -- fromList [ -- ("a", ServerMetadata 1000 Nothing), -- ("b", ServerMetadata 1000 (Just 1) -- ]
I tried using tableMap, and variety of combinations - but I was not able to get it to work. Appreciate any pointers on how to accomplish this.
tableMap
If it helps here is the raw toml.
Right ( TOML { tomlPairs = fromList [] , tomlTables = fromList [ ( "server" , Branch ( "server" :| [] ) Nothing ( fromList [ ( "a" , Leaf ( "a" :| [ "metadata" ] ) ( TOML { tomlPairs = fromList [ ( "port" :| [] , Integer 1000 ) ] , tomlTables = fromList [] , tomlTableArrays = fromList [] } ) ) , ( "b" , Leaf ( "b" :| [] ) ( TOML { tomlPairs = fromList [ ( "backoff" :| [] , Integer 1 ) ] , tomlTables = fromList [ ( "metadata" , Leaf ( "metadata" :| [] ) ( TOML { tomlPairs = fromList [ ( "port" :| [] , Integer 2000 ) ] , tomlTables = fromList [] , tomlTableArrays = fromList [] } ) ) ] , tomlTableArrays = fromList [] } ) ) ] ) ) ] , tomlTableArrays = fromList [] } )
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I've been trying to figure out how I can go about parsing something like following:
In this,
server.*.metadata
table exist - it could bea
,b
,c
,prod
,staging
and so on (not known ahead of time)I would like to parse it into following structure,
I tried using
tableMap
, and variety of combinations - but I was not able to get it to work. Appreciate any pointers on how to accomplish this.If it helps here is the raw toml.
The text was updated successfully, but these errors were encountered: