From 2903fd39c39357168a7cbb8b6821a0c99ed1e5a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sun, 26 Dec 2021 22:22:34 +0100 Subject: Generalize local state helper functions --- src/Contact.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/Contact.hs') diff --git a/src/Contact.hs b/src/Contact.hs index 9accc4d..e0f1a74 100644 --- a/src/Contact.hs +++ b/src/Contact.hs @@ -123,17 +123,15 @@ contactAccept printMsg h peer = do return (Nothing, OurRequestReady) OurRequestConfirm (Just ContactAccepted) -> do PeerIdentityFull pid <- peerIdentity peer - liftIO $ do - printMsg $ "Contact accepted" - updateLocalState_ h $ finalizeContact pid + liftIO $ printMsg $ "Contact accepted" + flip runReaderT h $ updateLocalState_ $ finalizeContact pid return (Nothing, PairingDone) OurRequestReady -> throwError $ "alredy accepted, waiting for peer" PeerRequest {} -> throwError $ "waiting for peer" PeerRequestConfirm -> do PeerIdentityFull pid <- peerIdentity peer - liftIO $ do - printMsg $ "Contact accepted" - updateLocalState_ h $ finalizeContact pid + liftIO $ printMsg $ "Contact accepted" + flip runReaderT h $ updateLocalState_ $ finalizeContact pid return (Just $ PairingAccept ContactAccepted, PairingDone) PairingDone -> throwError $ "alredy done" PairingFailed -> throwError $ "alredy failed" -- cgit v1.2.3