I want to write a Haskell program that queries information about a darcs repository. Instead of invoking the darcs executable and parse the results, I would rather use the darcs library directly. It is said to be "very much work in progress" and to "lack a stable API", but seems usable.
I think I could answer my questions by studying the darcsden source code, for example, starting with this module, but I think it may be helpful not only to me if someone knowledgeable would provide a commented introduction to supplement such a study.
So, here is a concrete example.
How can I compute for a given file the most recent patch that affected it along with the date, author, and name of the patch? It would be extra useful if you explain the key library functions used in your solution.
Edit:
Here are some remarks that might not be obvious to someone unfamiliar with the source code of darcs. I learned them from Jason Dagit's master thesis and hope they are helpful to understand the answer given by Ganesh.
In Darcs, patches have a pre- and a post-context representing the state of the repository before and after applying the patch. In source code, these contexts are modeled using phantom types on the type of patches. These phantom types are called witnesses and seal2
is used to get rid of them.
In lists of patches, only the very first pre-context and the very last post-context are represented in the type. All other contexts are hidden using existential types. Darcs defines forward lists (called FL) and reverse lists (called RL). Reverse lists store patches in reverse (chronological) order (modulo patch reordering done by darcs). Reverse lists can be used to access the most recent patch in the head position. All functions with RL in their name create or operate on such reverse lists.