Safe Haskell | Unsafe |
---|
This module implements the core of labeled IORef
s in the 'LIO ad.
to Data.IORef, but the operations take place in the LIO
monad. The
types and functions exported by this module are strictly TCB and do
not perform any information flow checks. The external, safe interface
is provided and documented in LIO.LIORef.
Different from many labeled objects (e.g., files or MVars), references are uni-directional. This means that reading from a reference can be done without being able to write to it; and writing to a refernece can be done without raising the current label, as if also performing a read.
- data LIORef l a = LIORefTCB {
- labelOfLIORef :: !l
- unlabelLIORefTCB :: IORef a
- newLIORefTCB :: MonadLIO l m => l -> a -> m (LIORef l a)
- readLIORefTCB :: MonadLIO l m => LIORef l a -> m a
- writeLIORefTCB :: MonadLIO l m => LIORef l a -> a -> m ()
- modifyLIORefTCB :: MonadLIO l m => LIORef l a -> (a -> a) -> m ()
- atomicModifyLIORefTCB :: MonadLIO l m => LIORef l a -> (a -> (a, b)) -> m b
Documentation
An LIORef
is an IORef
with an associated, fixed label. The
restriction to an immutable label come from the fact that it is
possible to leak information through the label itself, if we wish to
allow LIORef
to be an instance of LabelOf
. Of course, you can
create an LIORef
of Labeled
to get a limited form of
flow-sensitivity.
LIORefTCB | |
|
Basic Functions
Create labeled IORef
s
newLIORefTCB :: MonadLIO l m => l -> a -> m (LIORef l a)Source
Trusted constructor that creates labeled references with the given label without any IFC checks.
Read LIORef
s
readLIORefTCB :: MonadLIO l m => LIORef l a -> m aSource
Trusted function used to read the value of a reference without raising the current label.
Write LIORef
s
writeLIORefTCB :: MonadLIO l m => LIORef l a -> a -> m ()Source
Trusted function used to write a new value into a labeled reference, ignoring IFC.
Modify LIORef
s
modifyLIORefTCB :: MonadLIO l m => LIORef l a -> (a -> a) -> m ()Source
Trusted function that mutates the contents on an LIORef
,
ignoring IFC.
atomicModifyLIORefTCB :: MonadLIO l m => LIORef l a -> (a -> (a, b)) -> m bSource
Trusted function used to atomically modify the contents of a labeled reference, ignoring IFC.