Slipping from the Haskell Horse

For a long time I thought of myself as fairly competent in Haskell – I knew the language and most of its concepts and tricks. That’s no mean feat in Haskell, which eschews anything impure, and spends years searching for the correct abstraction for apparently-trivial impure features, finally adopting something mind-bending from category theory. However there’s been a burst of developments in the language, and a mainstreaming of esoteric concepts that are leaving my knowledge in the dust.

Years ago Haskell went through multiple iterations of an IO system before discovering the applicability of monads, and opening up the links between category theory and programming. Given the importance of IO to self-contained programs (especially the ones featured in tutorials), monads soon became something taught to near-beginners (and spawned increasingly strained analogies). This process seems to have occurred again, with Lenses and Pipes.

Haskell has struggled with a wonky record system (and many imperfect proposals to fix it) for many years, but recently the Lens abstraction was developed (composable getters and setters with OO-like syntax, all without special language support), and it’s now in the excellent Stanford course (which is pretty hardcore, starting off with how Haskell is compiled and represented in memory).

Pipes (or the iteratee concept) was developed in response to the pitfalls of lazy IO – essentially it’s a way to guarantee resource finalisation, which Haskell didn’t do well for a long time. Once again, it draws heavily from category theory, which makes it play nicely with all the existing abstractions and functions on those abstractions (eg monads, monad transformers, and functors), and gives Pipes (which is supposedly Control.Proxy now) nice properties that are currently beyond my understanding. The design of Pipes employs the idea of “free monads” from category theory; this concept is becoming mainstream within the Haskell community as a design technique.

As Lenses and Pipes address issues that are basic in impure languages, they are becoming foundation knowledge, and with the uptake of category theoretical structures in library design, I’ve got a lot to catch up on.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s