Friday, 28 October 2011

Haskell Actors

There's some recent interest about Actor-style concurrency in the Haskell context, e.g. see

My own work in this context, see actor, is orthogonal to the above mentioned works.

The main point of actor is the ability to pattern match over multiple events (messages) in the message queue. Here's a simple example. Suppose, you write a market-place actor which receives requests from sellers and buyers. The task is to find matching sellers and buyers. In the actor extension this can be elegantly specified as follows (I'm using some pseudo-syntax here):

receive Seller item & Buyer item --> ...

Try to express the same using standard actors where we can pattern match over a single message only. There's more info about actors with multi-headed receive clauses in some earlier post. Please check out the COORDINATION'08 paper (online) for the details of the matching algorithm which is implemented in actor.

I retrospect, I should have named the package 'multi-headed-actor', what a freaky name :)

The actor approach is built upon concurrent channels but instead we could rely on distributed channels based on haskell-mpi or ErlangInHaskell.

This idea (of receive patterns with multiple heads) has been picked up by others, e.g. see the following works which basically adopt the matching algorithm from actor

  • Hubert Plociniczak and Susan Eisenbach. JErlang: Erlang with Joins

  • Scala Joins Library:
    Implementing Joins using Extensible Pattern Matching
    by Philipp Haller and Tom Van Cutsem


MCAndre said...

actor fails to build in GHC 7. Could you please update this package to work with the current GHC version?

Martin Sulzmann said...

Yes, this is in the works, as well as upgrading to a more recent GHC version.
Quite hectic at my end (exam period), will work on this over the coming week-end.