module MAC.Effects
(
create
, writeup
, readdown
, fix
, read_and_fix
, write_and_fix
, rw_read
, rw_write
)
where
import MAC.Lattice
import MAC.Core
create :: Less l l' => IO (d a) -> MAC l (Res l' (d a))
create io = ioTCB io >>= return . MkRes
writeup :: Less l l' => (d a -> IO ()) -> Res l' (d a) -> MAC l ()
writeup io (MkRes a) = ioTCB $ io a
readdown :: Less l' l => (d a -> IO a) -> Res l' (d a) -> MAC l a
readdown io (MkRes da) = ioTCB $ io da
fix :: l -> MAC l ()
fix _ = return ()
read_and_fix :: Less l l => (d a -> IO a) -> Res l (d a) -> MAC l a
read_and_fix io r = fix (labelOf r) >> readdown io r
write_and_fix :: Less l' l' => (d a -> IO ()) -> Res l' (d a) -> MAC l' ()
write_and_fix io r = fix (labelOf r) >> writeup io r
rw_read :: (Less l l', Less l' l) => (d a -> IO a) -> Res l' (d a) -> MAC l a
rw_read io r = writeup (\_ -> return ()) r >> readdown io r
rw_write :: (Less l l', Less l' l) => (d a -> IO ()) -> Res l' (d a) -> MAC l ()
rw_write io r = readdown (\_ -> return undefined) r >> writeup io r