[darcs-users] A Plugin Architecture for Darcs

Nimrod A. Abing nimrod.abing at gmail.com
Tue Oct 31 03:50:25 UTC 2006


On 10/31/06, Eric Y. Kow <eric.kow at gmail.com> wrote:
> > As a result I have resorted to writing a wrapper script, which
> > currently only implements a very primitive "ignored patch lists"
> > handling.
>
> Out of curiosity, what are your languages of choice?

Not really by choice, I'm using C-like languages most of the time.
Programming for the web is currently where the money is right now so
most of the time I code in either PHP, Perl, Java, or Python.
Initially, I programmed in either C or C++ which I still do sometimes.

> I was nervous about functional programming at first (I remember fold
> being very hard for me to understand in uni), but now I can't imagine
> life without it.

Does Emacs Lisp count as a functional programming language? :) Haskell
sort of resembles Erlang with all those "arrows" and double colons.

I've been trying to learn Haskell on and off now for over I year I
think. The tutorials on the Haskell site assume too much about the
reader and they are hard to understand especially if you have been
doing imperative programming for so long (14 years or so).

I found this lately: http://www.haskell.org/~pairwise/intro/intro.html

It looks a bit easier to understand but still, it makes some
unnecessary assumptions about the reader.

> > Are there any plans to implement a plugin system for darcs that is
> > similar to the one provided by BazaarNG? I tried to search if there
> > are implementations of embeddable Haskell interpreters but so far,
> > I've come up empty. I'm guessing since darcs is written in Haskell,
> > then it should be extensible/scriptable using Haskell too. Plus it
> > would be a good motivation (at least for me) to get into Haskell
> > programming.
>
> I personally have not heard of any.
> Is something like hs-plugins what you're looking for?

I have not stepped out of the basic "Hello World" and tail-recursion
examples yet so honestly, I have no idea how hs-plugins work :)

The thing that sparked this idea of a scriptable plugin is that I have
been using a Haskell interpreter in my lessons so far. ghci and Hugs
are possible: a scripting environment for Haskell. So why not a
scripting environment for darcs using Haskell as the scripting
language? All of the interpreted languages that I use provides for a
way to embed the core interpreter in a C or C++ program. There are
plenty of embeddable Lisp interpreters around, Haskell interpreters
should be embeddable too.

As I have written in response to Jason, another approach would be to
specify a module interface. Since Haskell can access libraries written
in C, then it should be quite possible to write a Haskell wrapper
around glib module loading functions. Modules could be specified to
conform to the interface:

int moduleInterface(void* darcsInnards, int argc, char** argv)

This is similar to other module/plugin systems I have encountered. The
first parameter would be a pointer to the current internal state of
darcs. But this implementation is unsafe and it would be a lot safer
(and faster) to write plugins in Haskell script.
-- 
_nimrod_a_abing_

[?] http://abing.gotdns.com




More information about the darcs-users mailing list