[Haskell-cafe] Difficulties in accessing inner elements of data types

Sean Leather leather at cs.uu.nl
Thu Mar 5 20:22:20 EST 2009

Hi David,

I'm working on a Haskell library for interacting with emacs org files. For
> those that do not know, an org file is a structured outline style file that
> has nested headings, text, tables and other elements.
Great! Sounds like fun. :)

Now, this all works as expected (files are correctly being parsed and
> written), however I am having a lot of trouble trying to come up with a
> decent API to work with this. While writing an OrgFile is fairly easy,
> reading (and accessing inner parts) of an org file is very tedious, and
> modifying them is horrendous.

I can imagine.

> However, I don't know if this is even possible, how to do it, or if there
> is a better alternative to this. I would really apreciate any hints with
> regards to this. It would be useful to know if there are other libraries
> that also face this problem, and how they solved it.

I definite agree with Neil: I think generic programming is exactly what you
are looking for. Fortunately, there are a number of libraries available to
help you solve your problem. The next problem is figuring out which one and
learning how to it. For this purpose, a comparison of libraries for generic
programming in Haskell was recently published:


That should give you an idea of what's out there and the pros and cons of
each library.

I found your example particularly interesting, so I decided to try out a
solution in EMGM (Extensible and Modular Generics for the Masses). I wrote
up my experiment here:


More information on EMGM is here:


I'd be happy to help you figure out if EMGM is appropriate for other things
you want to do. Good luck with your library!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090306/bbf74641/attachment.htm

More information about the Haskell-Cafe mailing list