poetix

this time for sure

Note on Coalgebra

Unless I’m just kidding myself that I understood any of that paper on codata and comonads, the RBT module in my last Haskell exercise exports what is known as a final coalgebra.

Assuming that this is correct, is it a useful thing to know? Maybe not, or not until you know all the other things you need to know in order for it to become useful (let’s see, shall we?). On the other hand, I can see immediately the usefulness of the kind of encapsulation captured by the design pattern that I’ve implemented here (cribbing from the paper, which uses the same pattern to define a Stream coalgebra).

What’s more, it’s remarkably clear how the private and public faces of the RBT coalgebra (if that’s what it is) are related and distinguished: the semantics of hidden and visible are cleanly expressed through the type system and the module system. Which, in my book, is a definite win.