test
[clean-tests.git] / stampedShare / test.icl
index 1b2445c..9b62ee7 100644 (file)
@@ -1,73 +1,15 @@
 module test
 
-import Data.Func
 import iTasks.Extensions.DateTime
-import qualified Data.Map as DM
-import qualified Data.Set as DS
+import System.Time
 import iTasks
 
-//:: SDSStamped sds p r w = SDSStamped String (sds p (DateTime, r) (DateTime, w))
-//instance Identifiable (SDSStamped sds) | Identifiable sds
-//where
-//     nameSDS (SDSStamped n sds) acc = ["t$":nameSDS sds ["$t":acc]]
-//instance Readable (SDSStamped sds) | Readable sds
-//where
-//     readSDS (SDSStamped name sds) p c iworld
-//             = case readSDS sds p c iworld of
-//                     (Error e, iworld) = (Error e, iworld)
-//                     (Ok (ReadResult r ssds), iworld)
-//                             = (Ok (ReadResult r (SDSStamped name ssds)), iworld)
-//                     (Ok (AsyncRead sds), iworld)
-//                             = (Ok (AsyncRead (SDSStamped name sds)), iworld)
-//
-
-:: SDSNoNotify p r w = E.sds: SDSNoNotify (sds p r w) & RWShared sds
-instance Identifiable SDSNoNotify where
-       nameSDS (SDSNoNotify sds) c = nameSDS sds c
-instance Readable SDSNoNotify where
-   readSDS (SDSNoNotify sds) p c iworld
-               = case readSDS sds p c iworld of
-                       (Error e, iworld) = (Error e, iworld)
-                       (Ok (ReadResult r sds), iworld)
-                               = (Ok (ReadResult r sds), iworld)
-                       (Ok (AsyncRead sds), iworld)
-                               = (Ok (AsyncRead sds), iworld)
-
-instance Writeable SDSNoNotify where
-       writeSDS (SDSNoNotify sds) p c w iworld
-               = case writeSDS sds p c w iworld of
-                       (Error e, iworld) = (Error e, iworld)
-                       (Ok (WriteResult _ sds), iworld)
-                               = (Ok (WriteResult 'DS'.newSet (SDSNoNotify sds)), iworld)
-                       (Ok (AsyncWrite sds), iworld)
-                               = (Ok (AsyncWrite (SDSNoNotify sds)), iworld)
-instance Registrable SDSNoNotify where
-       readRegisterSDS (SDSNoNotify sds) p c _ _ iworld
-               = case readSDS sds p c iworld of
-                       (Error e, iworld) = (Error e, iworld)
-                       (Ok (ReadResult r sds), iworld)
-                               = (Ok (ReadResult r sds), iworld)
-                       (Ok (AsyncRead sds), iworld)
-                               = (Ok (AsyncRead sds), iworld)
-instance Modifiable SDSNoNotify where
-       modifySDS mf (SDSNoNotify sds) p c iworld
-               = case modifySDS mf sds p c iworld of
-                       (Error e, iworld) = (Error e, iworld)
-                       (Ok (ModifyResult _ r w sds), iworld)
-                               = (Ok (ModifyResult 'DS'.newSet r w (SDSNoNotify sds)), iworld)
-                       (Ok (AsyncModify sds mf), iworld)
-                               = (Ok (AsyncModify (SDSNoNotify sds) mf), iworld)
-
-
-sh = sharedStore "bork" ({DateTime|year=0,mon=0,day=0,hour=0,min=0,sec=0}, 42)
+sh = sharedStore "bork1" ({DateTime|year=0,mon=0,day=0,hour=0,min=0,sec=0}, 42)
+sh` = sharedStore "bork2" ({Timespec|tv_sec=0,tv_nsec=0}, 42)
 
 Start w = doTasks t w
-//Start w = nameSDS (SDSStamped "bork" sh) []
-
-stampedShare :: (Shared sds (DateTime, a)) -> SDSLens () (DateTime, a) a | TC a & RWShared sds
-stampedShare sds =
-       mapReadWrite (fst , \a (_, dt)->Just ((dt, a), dt)) Nothing
-       $ sds >*< (mapWrite (\_ _->Nothing) Nothing currentDateTime)
 
-t = viewSharedInformation [] sh
-       -&&- updateSharedInformation [] (stampedShare sh)
+t     =  viewSharedInformation [] sh
+       -&&- updateSharedInformation [] (dateTimeStampedShare sh)
+       -&&- viewSharedInformation [] sh`
+       -&&- updateSharedInformation [] (timespecStampedShare sh`)