I should start blogging again.
This week I published the first release of two Haskell libraries that fell out of early work I was doing on backup solution for Sandstorm. I’ll write more about the backup project in a later post, but for now, I figured I would write up the two small focused libraries I just pushed out to Hackage.
unix-simple
The first library is unix-simple. This is a fairly straightforward
binding to the Posix API; I got frustrated with the spotty nature of the
existing unix
package and the half dozen supplimentary packages
covering less used APIs. I wanted something that mapped to the
underlying C APIs in a way that was predictable enough that if you’re
familiar with posix you barely need to read the reference docs, and
that didn’t have huge gaps in the API that had to be filled in by other,
one-off packages.
There is actually a package with some overlapping goals already, posix-api, which at least aims to aggregate APIs into one package, but it still fails on some of my ergonomic criteria.
The README has more information.
lifetimes
The second package, lifetimes, is somewhat more interesting – I was
finding resourcet
a bit too limited for some of my needs, so I wrote
a package for more flexible resource management. resourcet
basically
lets you define a scope for resources and possibly release them early
within that scope. lifetimes
is more flexible, in particular:
- You can move resources between lifetimes.
- Lifetimes are values, and can themselves be acquired as resources.
- There’s a module for doing refcounting.
- There’s a module for working with GC finalizes. This one is pulled
from the source code of
haskell-capnp
, only lightly modified . It’s is often not what you want, but I included it both because:- the low level finalizer APIs from GHC are a bit error prone; this module makes it harder to shoot yourself in the foot in the same ways that I did when writing haskell-capnp.
- I wanted to be able to mix the stuff I’m doing with finalizers
already in haskell-capnp with the manual management the library
supports. Right now capabilities are handled via finalizers, but
sometimes a remote capability represents some resource that really
should be managed manually, so I want the flexibility for the user
to choose policy here. There’s more work needed in
haskell-capnp
still to integrate this.
I plan to supply integration packages for other things in the Haskell
ecosystem as well, notably async
and my supervisors package.
Cheers.