Closed Michael-Kateregga closed 6 years ago
I'm a little unclear on exactly what you're asking for but I think you're saying you have data like
text1,text2,natural1,text4,double1
and you will have a Dhall config file to your program that specifies the format of this log line.
You want to parse these log lines into some Haskell structure, but you say you don't want to define it. Your only real options are things like http://hackage.haskell.org/package/vinyl to define anonymous records, but I'd ask if you really want that. It might be worth considering why you don't want that record type, as it looks useful to me! The usual approach in Haskell is to come up with something inductive - maybe you want to parse into
[LogField]
where
data LogField = StringField String | NaturalField Natural | DoubleField Double
```.
So basically log lines turn into lists of fields.
I'll close this, but if that doesn't answer the question just say.
@ocharles yes you got my need right but I want Haskell to infer the LogField data structure from the dhall config instead of manually defining in Haskell. @Gabriel439 suggested I should create own tool that would do Text -> [Text] e.g.
"text1,text2,natural1,text4,double1" = ["text1","text2","natural1","text4","double1"].
I have a log: "text1,text2,natural1,text4,double1"
What I intend to do is to write a dhall config that I can decode in haskell to obtain a data structure: data Log { field1 :: String , field2 :: String , field3 :: Natural , field4 :: String , field5 :: Double }
without first defining the data structure in haskell. I would then do the same in other languages using their bindings w.r.t dhall.
Is this possible?