Jason Shipman

My name is Jason Shipman. I learned FP through the Oz language in school and became hooked on Haskell soon after. I strive to always write simple code and have a tendency to challenge the norms in regards to how Haskell applications can be architected… this is the part where one of my coworkers points at me while shouting “IO nihilist!" at the top of his lungs.

Context Is Everything*

“In this talk, we will learn what thread-indexed storage is all about, and how we can leverage it via the ‘context’ package. We’ll introduce the opaque ‘Store’ data type, which gives us thread-indexed storage around arbitrary context values. We will then see how we can safely nest context values from any number of threads. Context values are nested because they apply for the duration of a provided action, so we can register a context to make it available for a wrapped block of code. Within the provided action, we are free to nest context values further and further, for the durations of any inner actions. When an action completes, the thread’s current context reverts to the registered context prior to that action. We will also see how we can propagate a parent thread’s latest context values to a child thread (the quotes are there because in Haskell, threads do not have an explicit parent-child relationship).

This interface opens up quite a few doors when developing Haskell applications. After we have a feel for the interface, we will take a tour across a handful of these applications:

– Sharing a database connection in code that typically expects acquiring a connection from a pool
– Hierarchical logging
– Transparently providing authorization info to ‘servant’ endpoints without touching the API definition at all
– Conveniently making dependencies available throughout an application by combining thread-indexed storage with implicit parameters

The repo for the interface that will be discussed in this talk is at https://github.com/jship/context, and an initial release of ‘context’ is coming soon to a Hackage near you!"