code / art / projects

PEZ: The Potentially-Excellent Zipper Library Release

I’m happy to announce the release of a zipper library I namedPEZ! 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!