I’d like to write a Haskell library to work with a web service API. I get an XML or JSON response from the server, say it looks like this:
<foo>
<bar>1</bar>
<baz>moo</baz>
</foo>
I want to turn it into a record:
data Foo = Foo {
bar :: Integer,
baz :: String
}
How can I abstract this so that I don’t have to manually parse the XML and pick the individual components by hand? I hoped for an API that would let me describe the mapping from the XML elements and attributes to the record parts and do the rest for me.