makeChange collection (ModifyContent key val) =
Map.adjust (\_ -> val) key collection
in foldl makeChange collection commands
+
+{- | Given the base input and a ModifyContent command, convert this to
+commands to sync. Ignores anything that is not a ModifyContent command
+by returning an empty list. -}
+modifyToSync :: (Eq k, Ord k, Show k) =>
+ SyncCollection k v
+ -> SyncCommand k v
+ -> [SyncCommand k v]
+modifyToSync base (ModifyContent k v) =
+ case Map.lookup k base of
+ Nothing -> error $ "modifyToSync: attempt to modify on unknown base key " ++ show k
+ Just basev ->
+ diffCollection basev v
+modifyToSync _ _ = []
newcoll2 = unaryApplyChanges coll1 commands
in coll2 @=? newcoll2
+prop_modifyToSyncSimple :: SyncCollection Int Word8 -> Word8 -> Result
+prop_modifyToSyncSimple base newv
+ | Map.empty base = True @=? True
+ | otherwise = ([], [], [ModifyContent @=?
+ where k = fst . head . Map.toList base
+prop_modifyToSync
+
q :: Testable a => String -> a -> HU.Test
q = qccheck (defaultConfig {configMaxTest = 250})