diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2020-02-04 23:28:46 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2020-02-04 23:28:46 +0100 |
commit | 8dc945aae35fffd8e64c524b71d7316297721daf (patch) | |
tree | d1a000e303f6a22fdcf522b2b4729a81ea0c2fcc /src/Sync.hs | |
parent | 6f0bcff200598d085c89d167aa126d25fc5df3ed (diff) |
Service: unify service and packet types
Also provide default unit definition for the service state.
Diffstat (limited to 'src/Sync.hs')
-rw-r--r-- | src/Sync.hs | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/src/Sync.hs b/src/Sync.hs index 37941b8..afb45e6 100644 --- a/src/Sync.hs +++ b/src/Sync.hs @@ -1,6 +1,5 @@ module Sync ( - SyncService, - ServicePacket(..), + SyncService(..), ) where import Control.Monad @@ -12,16 +11,11 @@ import State import Storage import Storage.Merge -data SyncService +data SyncService = SyncPacket (Stored SharedState) instance Service SyncService where serviceID _ = mkServiceID "a4f538d0-4e50-4082-8e10-7e3ec2af175d" - data ServiceState SyncService = SyncService - emptyServiceState = SyncService - - newtype ServicePacket SyncService = SyncPacket (Stored SharedState) - serviceHandler packet = do let SyncPacket added = fromStored packet ls <- svcGetLocal @@ -31,6 +25,6 @@ instance Service SyncService where when (current /= updated) $ do svcSetLocal =<< wrappedStore st (fromStored ls) { lsShared = updated } -instance Storable (ServicePacket SyncService) where +instance Storable SyncService where store' (SyncPacket smsg) = store' smsg load' = SyncPacket <$> load' |