summaryrefslogtreecommitdiff
path: root/src/Service.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2022-07-17 21:51:30 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2022-07-17 22:32:55 +0200
commit479b63d8c30c0bc6e6475882d7fb573db5dad1f9 (patch)
treeaf2ebc889628de1b7c8dfdb3ed64d5733ba00bb4 /src/Service.hs
parent36eb3a419ec9d0434f55456090e2845d4ac20b58 (diff)
MonadStorage for context with Storage instance
Diffstat (limited to 'src/Service.hs')
-rw-r--r--src/Service.hs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/Service.hs b/src/Service.hs
index 7d5c7e7..22c983b 100644
--- a/src/Service.hs
+++ b/src/Service.hs
@@ -111,6 +111,9 @@ data ServiceHandlerState s = ServiceHandlerState
newtype ServiceHandler s a = ServiceHandler (ReaderT (ServiceInput s) (WriterT [ServiceReply s] (StateT (ServiceHandlerState s) (ExceptT String IO))) a)
deriving (Functor, Applicative, Monad, MonadReader (ServiceInput s), MonadWriter [ServiceReply s], MonadState (ServiceHandlerState s), MonadError String, MonadIO)
+instance MonadStorage (ServiceHandler s) where
+ getStorage = asks $ peerStorage . svcPeer
+
instance MonadHead LocalState (ServiceHandler s) where
updateLocalHead f = do
(ls, x) <- liftIO . f =<< gets svcLocal