MIT licensed and maintained by Jason Shipman
This version can be pinned in stack with:context-,1891


Version badge

context provides thread-indexed storage around arbitrary context values. The interface supports nesting context values per thread, and at any point, the calling thread may ask for their current context.


{-# LANGUAGE BlockArguments #-}

import qualified Context

data Thing = Thing
  { stuff :: Int

main :: IO ()
main = do
  Context.withEmptyStore \store -> do
    Context.use store Thing { stuff = 1 } do
      Context.use store Thing { stuff = 2 } do
        thing2 <- Context.mine store
        -- ...
      number1 <- Context.mines store stuff

See the Haddocks for more info on the library.


Change log

  • Backwards compatibility with GHC 8.4 (@pbrisbin)

  • Lift signatures from IO to MonadIO, MonadThrow and MonadMask
  • Type parameter order is now explicit via ScopedTypeVariables
  • Add withAdjusted convenience function
  • Re-export Context.View module from Context.Implicit

  • Correct Haddocks

  • Add Context.View module, which includes the View type + view, viewMay, and toView functions
  • Re-export Context.View from Context

  • Initial release