[Haskell-beginners] Is there an aeson-like XML serialization library?

Thomas Koster tkoster at gmail.com
Tue Mar 31 09:54:40 UTC 2015


Michael,

On 31 March 2015 at 14:26, Thomas Koster <tkoster at gmail.com> wrote:

> I want to write a simple XML web service in Haskell that services a .NET
> WCF client, but am struggling with choosing the right XML library.
> ...
> I need the library to understand XML namespaces and the mandatory
> predefined entities, but I do not need any other extensions like XML
> Schemas, XPath or XSLT. Preferably, "xmlns" attributes should be handled
> specially and namespace prefixes resolved by the parser. "xmlns" attributes
> should be placed automatically by the renderer (I don't care what prefixes
> it chooses). I do not want to have to keep track of seen namespace prefixes
> while I am traversing the document, or to manually place "xmlns" attributes
> on elements for rendering.


On 31 March 2015 at 16:39, Michael Snoyman <michael at snoyman.com> wrote:

> It doesn't have the typeclass stuff built in, but xml-conduit has proper
> support for XML namespaces.


That's OK. I can create the type classes myself.

class ToElement a where
  toElement :: a -> Element

class FromElement a where
  parseElement :: Element -> Either String a

The important thing is that namespaces are understood so that I am able
create instances that compose, e.g. (off the top of my head)

data SoapEnvelope h b = SoapEnvelope
  {
    soapEnvelopeHeaders :: [h],
    soapEnvelopeBody :: b
  }

instance (FromElement h, FromElement b) => FromElement (SoapEnvelope h b)
where
  parseElement e = SoapEnvelope <$> (...headers...) <*> (...body...)

Thanks,
--
Thomas Koster
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150331/06cc5255/attachment.html>


More information about the Beginners mailing list