implementation module ASDS
+import StdEnv
+
import Data.Functor
import Control.Monad
import Control.Monad.State
updShare :: (r -> w) (sds m () r w) -> PViewT m w | Monad m & read sds & write sds & TC r & TC w
updShare f s = f <$> getShare s >>= \v->setShare v s >>| liftT (pure v)
+
+trigger :: (p -> Bool) -> PViewT m () | TC p & Monad m
+trigger inv = gets (filter (match inv)) >>= mapM_ run
+where
+ match :: (p -> Bool) (NRequest m) -> Bool | TC p
+ match inv (NRequest oid ohnd (a :: p^)) = inv a
+ match _ _ = False
+
+ run :: (NRequest m) -> PViewT m () | Monad m
+ run (NRequest oid ohnd _) = liftT ohnd
instance MonadFail (Either String) where fail s = Left s
-
readwrite :: r w (sds m () r w) -> PViewT m () | MonadFail m & read sds & write sds & TC r & TC w & == r
readwrite r w sds = equal r (setShare w sds >>| getShare sds)