XML <--> Haskell Data Structure using HXT

44 views
Skip to first unread message

Han Joosten

unread,
Sep 11, 2014, 7:57:49 AM9/11/14
to haskel...@googlegroups.com
I would like to write code to enable importing data to and fro from a Haskell data structure. It makes sense to have some XSD or so that specifies how the XML should be structured. The HDS is already in place. I have been looking into hte HXT library and I think it could be used for this job. However, I am not familiar (yet) with Arrows and the like. Also the use of picklers is new to me. It would help me a lot if someone has a neat example of how coversion between XML and some Haskell data structure can be implemented in het HXT-style.
Do such examples exist? Where can I find them?


Cheers & Thanks for reading!

Han Joosten

Adam Bergmark

unread,
Sep 11, 2014, 8:11:26 AM9/11/14
to Han Joosten, haskel...@googlegroups.com
Apparently the original message was sent to the google group, didn't know that existed.  haskel...@haskell.org is the advertised address.


On Thu, Sep 11, 2014 at 2:06 PM, Adam Bergmark <ad...@bergmark.nl> wrote:
Hi Han,

Do you want to control the XML format? If not you can use regular-xmlpickler [1] to derive the serializations automatically.

We have some instances spread around in the rest project [2][3], but we're not doing very complicated things in the manually defined instances afaik.

I'm in no way an hxt expert. It was a bit tricky at first but I managed to write some picklers eventually :-)

Cheers,
Adam



_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



Erik Hesselink

unread,
Sep 11, 2014, 8:15:00 AM9/11/14
to haskell
We use HXT's picklers, and have written a blog post about it [1]. I
just saw that the code isn't formatted that great on our new blog,
I'll see if we can fix that. We also wrote a library [2] for
generically deriving instances for picklers, which we also blogged
about [3]. I hope that helps!

Regards,

Erik

[1] http://engineering.silk.co/post/31921413529/haskell-data-types-and-xml
[2] http://hackage.haskell.org/package/regular-xmlpickler
[3] http://engineering.silk.co/post/31922245822/writing-a-generic-xml-pickler

On Thu, Sep 11, 2014 at 1:57 PM, Han Joosten <han.joo...@gmail.com> wrote:

Han Joosten

unread,
Sep 11, 2014, 9:38:19 AM9/11/14
to haskel...@googlegroups.com, haskell
Thanks a lot for the pointers. They are spot on, and just what I was looking for!

--
You received this message because you are subscribed to a topic in the Google Groups "Haskell-cafe" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/haskell-cafe/YkePH-LbeSo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to haskell-cafe...@googlegroups.com.
To post to this group, send email to haskel...@googlegroups.com.
Visit this group at http://groups.google.com/group/haskell-cafe.
For more options, visit https://groups.google.com/d/optout.

Michael Orlitzky

unread,
Sep 11, 2014, 12:31:53 PM9/11/14
to haskel...@haskell.org
On 09/11/2014 07:57 AM, Han Joosten wrote:
> I would like to write code to enable importing data to and fro from a
> Haskell data structure. It makes sense to have some XSD or so that
> specifies how the XML should be structured. The HDS is already in place.
> I have been looking into hte HXT library and I think it could be used
> for this job. However, I am not familiar (yet) with Arrows and the like.
> Also the use of picklers is new to me. It would help me a lot if someone
> has a neat example of how coversion between XML and some Haskell data
> structure can be implemented in het HXT-style.
> Do such examples exist? Where can I find them?

I use these extensively in,

http://hackage.haskell.org/package/htsn-import

Each module under the TSN.XML namespace is basically a big XML <->
Haskell converter along with some database stuff.
Reply all
Reply to author
Forward
0 new messages