simple-actors: a simple Actor Model concurrency library

30/05/2011

EDIT: I’ve just released version 0.1.0 of this library. It is a complete re-write / re-think that I think makes the library much more attractive, simple and powerful. There won’t be any more dramatic API changes.

I was in need of a simple, tight library implementing the Actor Model of concurrency and didn’t find one on hackage, so I wrote my own. You can check out the docs here and get it with a

$ cabal install simple-actors

The library is really just a thin layer around Chans, and I made no great effort to ensure that the library conforms to any particular formal definition of the actor model, but rather tried to make an idiomatic haskell library for more structured concurrent programming.

I’ve been going all sorts of ways with this and would appreciate any feedback anyone would like to share.

I’ll be using it in some (hopefully fun and interesting) posts in the near future, to model concurrent systems, and also exploring creating a more involved concurrency library. So stay tuned if that’s what you’re into.

5 Comments

PEZ: the Potentially-Excellent Zipper library release

19/04/2011

I’m happy to announce the release of a zipper library I named PEZ! I’ve been learning and building this silly library almost as long as I’ve been learning haskell. It’s not as great as it could be, but I’m releasing it now because it’s about time.

You can check it out with a:

cabal install pez

The library provides a generic zipper that can be used on all types in the Typeable class, for which the user defines (or generates) lenses from the excellent fclabels package.

Since Typeable instances are deriveable in GHC and fclabels lenses can be generated with a line of TH code, this makes for a very pain-free and intuitive zipper.

The Typeable class gives us the ability to move up and down through complex mutually-recursive structures, even “down through” reversible computations!

The lenses from ‘fclabels’ give us a way of referring to elements in data types in a way that is composable, allowing us to store our history as continuations and provide powerful mechanisms for “saving” a path through a data structure.

There is more to do: in particular I haven’t yet examined any of the performance characteristics of the approach I take, but please try it out and let me know how it works for you!

No Comments

When is it okay to “fail”?

16/02/2011

That’s the question.

In designing a couple libraries the question of the proper use of the Monad class’s fail method has come up more than once.

On the one hand, many people consider fail to be a wart on the face of an otherwise pure implementation of an elegant construction borrowed from category theory. It’s as if someone defined scissors as

“two metal blades with handles, attached by a pivot… plus a bandaid in case you cut yourself”.

But on the other hand many instances of Monad have a logical and intuitive way of encapsulating failure, whether it be Nothing in Maybe, or the empty list in []. And for monad’s that have no reasonable way of encapsulating failure, a default method (raising an exception) can be used.

Read the rest of this article »

No Comments