Skip to content

Commit f45f5a2

Browse files
committed
refactor pattern match for ghc 8.10.7
1 parent 0c75f89 commit f45f5a2

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/Simplex/Messaging/Server.hs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,12 +1419,12 @@ client
14191419
processCommand :: Maybe ServiceId -> VersionSMP -> VerifiedTransmission s -> M s (Maybe ResponseAndMessage)
14201420
processCommand clntServiceId clntVersion (q_, (corrId, entId, cmd)) = case cmd of
14211421
Cmd SProxiedClient command -> processProxiedCmd (corrId, entId, command)
1422-
Cmd SSender command -> response <$> case command of
1422+
Cmd SSender command -> case command of
14231423
SKEY k -> withQueue $ \q qr -> checkMode QMMessaging qr $ secureQueue_ q k
1424-
SEND flags msgBody -> withQueue_ False err $ sendMessage flags msgBody
1424+
SEND flags msgBody -> response <$> withQueue_ False err (sendMessage flags msgBody)
14251425
Cmd SIdleClient PING -> pure $ response (corrId, NoEntity, PONG)
14261426
Cmd SProxyService (RFWD encBlock) -> response . (corrId,NoEntity,) <$> processForwardedCommand encBlock
1427-
Cmd SSenderLink command -> response <$> case command of
1427+
Cmd SSenderLink command -> case command of
14281428
LKEY k -> withQueue $ \q qr -> checkMode QMMessaging qr $ secureQueue_ q k $>> getQueueLink_ q qr
14291429
LGET -> withQueue $ \q qr -> checkContact qr $ getQueueLink_ q qr
14301430
Cmd SNotifier NSUB -> response . (corrId,entId,) <$> case q_ of
@@ -1439,9 +1439,9 @@ client
14391439
allowNew = do
14401440
ServerConfig {allowNewQueues, newQueueBasicAuth} <- asks config
14411441
pure $ allowNewQueues && maybe True ((== auth_) . Just) newQueueBasicAuth
1442-
Cmd SRecipient SUB -> Just <$> withQueue' subscribeQueueAndDeliver
14431442
Cmd SRecipient command ->
1444-
response <$> case command of
1443+
case command of
1444+
SUB -> withQueue' subscribeQueueAndDeliver
14451445
GET -> withQueue getMessage
14461446
ACK msgId -> withQueue $ acknowledgeMsg msgId
14471447
KEY sKey -> withQueue $ \q _ -> either err (corrId,entId,) <$> secureQueue_ q sKey
@@ -1457,8 +1457,8 @@ client
14571457
Nothing -> pure ok
14581458
NKEY nKey dhKey -> withQueue $ \q _ -> addQueueNotifier_ q nKey dhKey
14591459
NDEL -> withQueue $ \q _ -> deleteQueueNotifier_ q
1460-
OFF -> maybe (pure $ err INTERNAL) suspendQueue_ q_
1461-
DEL -> maybe (pure $ err INTERNAL) delQueueAndMsgs q_
1460+
OFF -> response <$> maybe (pure $ err INTERNAL) suspendQueue_ q_
1461+
DEL -> response <$> maybe (pure $ err INTERNAL) delQueueAndMsgs q_
14621462
QUE -> withQueue $ \q qr -> (corrId,entId,) <$> getQueueInfo q qr
14631463
Cmd SRecipientService SUBS -> pure $ response $ err (CMD PROHIBITED) -- "TODO [certs rcv]"
14641464
where
@@ -1666,11 +1666,13 @@ client
16661666
atomically $ setDelivered s msg ts $> (corrId, entId, MSG encMsg)
16671667
Nothing -> incStat (msgGetNoMsg stats) $> ok
16681668

1669-
withQueue :: (StoreQueue s -> QueueRec -> M s (Transmission BrokerMsg)) -> M s (Transmission BrokerMsg)
1670-
withQueue = withQueue_ True err
1669+
withQueue :: (StoreQueue s -> QueueRec -> M s (Transmission BrokerMsg)) -> M s (Maybe ResponseAndMessage)
1670+
withQueue = fmap response . withQueue_ True err
1671+
{-# INLINE withQueue #-}
16711672

1672-
withQueue' :: (StoreQueue s -> QueueRec -> M s ResponseAndMessage) -> M s ResponseAndMessage
1673-
withQueue' = withQueue_ True ((,Nothing) . err)
1673+
withQueue' :: (StoreQueue s -> QueueRec -> M s ResponseAndMessage) -> M s (Maybe ResponseAndMessage)
1674+
withQueue' = fmap Just . withQueue_ True ((,Nothing) . err)
1675+
{-# INLINE withQueue' #-}
16741676

16751677
-- SEND passes queueNotBlocked False here to update time, but it fails anyway on blocked queues (see code for SEND).
16761678
withQueue_ :: Bool -> (ErrorType -> r) -> (StoreQueue s -> QueueRec -> M s r) -> M s r

0 commit comments

Comments
 (0)