Safe Haskell | None |
---|---|
Language | Haskell2010 |
- newtype ContextID = ContextID Int
- nextContextID :: IORef ContextID
- newContextID :: IO ContextID
- runningContexts :: IORef (Map ThreadId ContextID)
- contextLocalData :: IORef (IntMap (Map TypeRep Dynamic))
- currentContextID :: MonadIO m => m (Maybe ContextID)
- storeContextLocalData :: (MonadIO m, Typeable a) => a -> m ()
- retrieveContextLocalData :: forall m a. (MonadIO m, Typeable a) => m a -> m a
Documentation
The type of a Caramia context ID.
currentContextID :: MonadIO m => m (Maybe ContextID) Source
Returns the current Caramia context ID.
The context ID is unique between different calls to giveContext
.
Returns Nothing
if there is no context active.
storeContextLocalData :: (MonadIO m, Typeable a) => a -> m () Source
Stores a context local value.
The type of the given value is used as a key. This means that if a value of the same type was stored before, that value is thrown away and replaced with this new value you just gave.
The value is evaluated to WHNF.
You don't need this function to work with context local data.
retrieveContextLocalData
is sufficient as it also lets you set a default
value in case a value was not already set.
Context local data is wiped to oblivion once giveContext
ends.
retrieveContextLocalData Source
:: (MonadIO m, Typeable a) | |
=> m a | Default value generating action; not evaluated if there was already a value stored. |
-> m a |
Retrieves a context local value.