Hi David,<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="font-family: &#39;Consolas&#39;; font-size: 10pt; font-weight: 400; font-style: normal;">
I&#39;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.<br>
<p style="margin: 0px; text-indent: 0px;"></p></div></blockquote><div><br>Great! Sounds like fun. :)<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="font-family: &#39;Consolas&#39;; font-size: 10pt; font-weight: 400; font-style: normal;">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.<br>

</div></blockquote><div><br>I can imagine.<br></div><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="font-family: &#39;Consolas&#39;; font-size: 10pt; font-weight: 400; font-style: normal;">
However, I don&#39;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.<br>
</div></blockquote></div><br>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:<br>
<br>  <a href="http://www.cs.uu.nl/wiki/Alexey/ComparingLibrariesForGenericProgrammingInHaskell">http://www.cs.uu.nl/wiki/Alexey/ComparingLibrariesForGenericProgrammingInHaskell</a><br><br>That should give you an idea of what&#39;s out there and the pros and cons of each library.<br>
<br>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:<br><br>  <a href="http://splonderzoek.blogspot.com/2009/03/experiments-with-emgm-emacs-org-files.html">http://splonderzoek.blogspot.com/2009/03/experiments-with-emgm-emacs-org-files.html</a><br>
<br>More information on EMGM is here:<br><br>  <a href="http://www.cs.uu.nl/wiki/GenericProgramming/EMGM">http://www.cs.uu.nl/wiki/GenericProgramming/EMGM</a><br><br>I&#39;d be happy to help you figure out if EMGM is appropriate for other things you want to do. Good luck with your library!<br>
<br>Regards,<br>Sean<br>