May 17, 2013

Zippers and Comonads

The term zipper is a colloquial used to describe n-hole (most often, 1-hole) contexts. That is, a data structure that has a hole or pointer focused on a specific element with the ability to efficiently traverse to its neighbouring elements, providing an elegant solution for the need to efficiently traverse and modify immutable data structures.

Comonads, the categorical dual of Monads, provide an abstraction for dealing with types that allow extraction. That is, the ability to take a value out of a context; for example, the fact that it is a total operation to extract the head of a non-empty list.

In this talk and workshop, we will do a deep dive into the implementation of purely-functional data structures in Scala. Exploring zippers, Comonads, their relationship and Scala specific implementation techniques.

This talk was presented by myself and Tony Morris at YOW! LambdaJam 2013. The talk was accompanied by a programming workshop which gave participants an opportunity to put these patterns into practice.

[ deck ] [ code ]