Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type ContextID = Int
- runningContexts :: IORef (Map ThreadId ContextID)
- nextContextID :: IORef ContextID
- contextLocalData :: IORef (IntMap (Map TypeRep Dynamic))
- currentContextID :: IO (Maybe ContextID)
- storeContextLocalData :: Typeable a => a -> IO ()
- retrieveContextLocalData :: forall a. Typeable a => IO a -> IO a
Documentation
currentContextID :: IO (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 :: Typeable a => a -> IO () 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
:: forall a . Typeable a | |
=> IO a | Default value generating action; not evaluated if there was already a value stored. |
-> IO a |
Retrieves a context local value.