summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Crypto/Transport.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox/Crypto/Transport.hs')
-rw-r--r--src/Network/Tox/Crypto/Transport.hs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs
index 2c13e168..a18b550d 100644
--- a/src/Network/Tox/Crypto/Transport.hs
+++ b/src/Network/Tox/Crypto/Transport.hs
@@ -44,7 +44,7 @@ module Network.Tox.Crypto.Transport
44 , HasMessage(..) 44 , HasMessage(..)
45 , HasMessageType(..) 45 , HasMessageType(..)
46 -- lenses 46 -- lenses
47#ifdef VERSION_lens 47#ifdef USE_lens
48 , groupNumber, groupNumberToJoin, peerNumber, messageNumber 48 , groupNumber, groupNumberToJoin, peerNumber, messageNumber
49 , messageName, messageData, name, title, message, messageType 49 , messageName, messageData, name, title, message, messageType
50#endif 50#endif
@@ -288,7 +288,7 @@ putCryptoMessage seqno (Pkt t :=> Identity x) = do
288 putPacket seqno x 288 putPacket seqno x
289 289
290 290
291#ifdef VERSION_lens 291#ifdef USE_lens
292erCompat :: String -> a 292erCompat :: String -> a
293erCompat lens = error $ "Use of '" ++ lens ++ "' lens on incompatible CryptoMessage type" 293erCompat lens = error $ "Use of '" ++ lens ++ "' lens on incompatible CryptoMessage type"
294#endif 294#endif
@@ -336,7 +336,7 @@ instance HasGroupChatID CryptoMessage where
336 setGroupChatID _ _= error "setGroupChatID on non-groupchat message." 336 setGroupChatID _ _= error "setGroupChatID on non-groupchat message."
337-} 337-}
338 338
339#ifdef VERSION_lens 339#ifdef USE_lens
340groupChatID :: (Functor f, HasGroupChatID x) => (GroupChatId -> f GroupChatId) -> (x -> f x) 340groupChatID :: (Functor f, HasGroupChatID x) => (GroupChatId -> f GroupChatId) -> (x -> f x)
341groupChatID = lens getGroupChatID setGroupChatID 341groupChatID = lens getGroupChatID setGroupChatID
342#endif 342#endif
@@ -370,7 +370,7 @@ instance HasGroupNumber CryptoMessage where
370 setGroupNumber _ _ = error "setGroupNumber on CryptoMessage without group number field." 370 setGroupNumber _ _ = error "setGroupNumber on CryptoMessage without group number field."
371-} 371-}
372 372
373#ifdef VERSION_lens 373#ifdef USE_lens
374groupNumber :: (Functor f, HasGroupNumber x) => (Word16 -> f Word16) -> (x -> f x) 374groupNumber :: (Functor f, HasGroupNumber x) => (Word16 -> f Word16) -> (x -> f x)
375groupNumber = lens getGroupNumber setGroupNumber 375groupNumber = lens getGroupNumber setGroupNumber
376#endif 376#endif
@@ -394,7 +394,7 @@ instance HasGroupNumberToJoin CryptoMessage where
394 setGroupNumberToJoin _ _ = error "setGroupNumberToJoin on CryptoMessage without group number (to join) field." 394 setGroupNumberToJoin _ _ = error "setGroupNumberToJoin on CryptoMessage without group number (to join) field."
395-} 395-}
396 396
397#ifdef VERSION_lens 397#ifdef USE_lens
398groupNumberToJoin :: (Functor f, HasGroupNumberToJoin x) => (GroupNumber -> f GroupNumber) -> (x -> f x) 398groupNumberToJoin :: (Functor f, HasGroupNumberToJoin x) => (GroupNumber -> f GroupNumber) -> (x -> f x)
399groupNumberToJoin = lens getGroupNumberToJoin setGroupNumberToJoin 399groupNumberToJoin = lens getGroupNumberToJoin setGroupNumberToJoin
400#endif 400#endif
@@ -418,7 +418,7 @@ instance HasPeerNumber CryptoMessage where
418 setPeerNumber _ _ = error "setPeerNumber on CryptoMessage without peer number field." 418 setPeerNumber _ _ = error "setPeerNumber on CryptoMessage without peer number field."
419-} 419-}
420 420
421#ifdef VERSION_lens 421#ifdef USE_lens
422peerNumber :: (Functor f, HasPeerNumber x) => (Word16 -> f Word16) -> (x -> f x) 422peerNumber :: (Functor f, HasPeerNumber x) => (Word16 -> f Word16) -> (x -> f x)
423peerNumber = lens getPeerNumber setPeerNumber 423peerNumber = lens getPeerNumber setPeerNumber
424#endif 424#endif
@@ -442,7 +442,7 @@ instance HasMessageNumber CryptoMessage where
442 setMessageNumber _ _ = error "setMessageNumber on CryptoMessage without message number field." 442 setMessageNumber _ _ = error "setMessageNumber on CryptoMessage without message number field."
443-} 443-}
444 444
445#ifdef VERSION_lens 445#ifdef USE_lens
446messageNumber :: (Functor f, HasMessageNumber x) => (Word32 -> f Word32) -> (x -> f x) 446messageNumber :: (Functor f, HasMessageNumber x) => (Word32 -> f Word32) -> (x -> f x)
447messageNumber = lens getMessageNumber setMessageNumber 447messageNumber = lens getMessageNumber setMessageNumber
448#endif 448#endif
@@ -468,7 +468,7 @@ instance HasMessageName CryptoMessage where
468 setMessageName _ _ = error "setMessageName on CryptoMessage without message name field." 468 setMessageName _ _ = error "setMessageName on CryptoMessage without message name field."
469-} 469-}
470 470
471#ifdef VERSION_lens 471#ifdef USE_lens
472messageName :: (Functor f, HasMessageName x) => (MessageName -> f MessageName) -> (x -> f x) 472messageName :: (Functor f, HasMessageName x) => (MessageName -> f MessageName) -> (x -> f x)
473messageName = lens getMessageName setMessageName 473messageName = lens getMessageName setMessageName
474#endif 474#endif
@@ -514,7 +514,7 @@ instance AsWord64 MessageType where
514 fromWord64 x | x < 1024, x .|. 0x0200 == 0x0200 = GrpMsg (toEnum8 ((x - 512) `div` 256)) (toEnum8 x) 514 fromWord64 x | x < 1024, x .|. 0x0200 == 0x0200 = GrpMsg (toEnum8 ((x - 512) `div` 256)) (toEnum8 x)
515 fromWord64 x = error "Not clear how to convert Word64 to MessageType" 515 fromWord64 x = error "Not clear how to convert Word64 to MessageType"
516 516
517#ifdef VERSION_lens 517#ifdef USE_lens
518word16 :: (Functor f, AsWord16 x) => (Word16 -> f Word16) -> (x -> f x) 518word16 :: (Functor f, AsWord16 x) => (Word16 -> f Word16) -> (x -> f x)
519word16 = lens toWord16 (\_ x -> fromWord16 x) 519word16 = lens toWord16 (\_ x -> fromWord16 x)
520#endif 520#endif
@@ -559,7 +559,7 @@ instance HasMessageType CryptoData where
559 setMessageType cd@(CryptoData { bufferData=bd }) typ = cd { bufferData=setMessageType bd typ } 559 setMessageType cd@(CryptoData { bufferData=bd }) typ = cd { bufferData=setMessageType bd typ }
560-} 560-}
561 561
562#ifdef VERSION_lens 562#ifdef USE_lens
563-- | This lens should always succeed on CryptoMessage 563-- | This lens should always succeed on CryptoMessage
564messageType :: (Functor f, HasMessageType x) => (MessageType -> f MessageType) -> (x -> f x) 564messageType :: (Functor f, HasMessageType x) => (MessageType -> f MessageType) -> (x -> f x)
565messageType = lens getMessageType setMessageType 565messageType = lens getMessageType setMessageType
@@ -589,7 +589,7 @@ instance HasMessageData CryptoMessage where
589 setMessageData _ _ = error "setMessageData on CryptoMessage without message data field." 589 setMessageData _ _ = error "setMessageData on CryptoMessage without message data field."
590-} 590-}
591 591
592#ifdef VERSION_lens 592#ifdef USE_lens
593messageData :: (Functor f, HasMessageData x) => (MessageData -> f MessageData) -> (x -> f x) 593messageData :: (Functor f, HasMessageData x) => (MessageData -> f MessageData) -> (x -> f x)
594messageData = lens getMessageData setMessageData 594messageData = lens getMessageData setMessageData
595#endif 595#endif
@@ -621,7 +621,7 @@ instance HasTitle CryptoMessage where
621 setTitle _ _ = error "setTitle on CryptoMessage without title field." 621 setTitle _ _ = error "setTitle on CryptoMessage without title field."
622-} 622-}
623 623
624#ifdef VERSION_lens 624#ifdef USE_lens
625title :: (Functor f, HasTitle x) => (Text -> f Text) -> (x -> f x) 625title :: (Functor f, HasTitle x) => (Text -> f Text) -> (x -> f x)
626title = lens getTitle setTitle 626title = lens getTitle setTitle
627#endif 627#endif
@@ -653,7 +653,7 @@ instance HasMessage CryptoMessage where
653 setMessage _ _ = error "setMessage on CryptoMessage without message field." 653 setMessage _ _ = error "setMessage on CryptoMessage without message field."
654-} 654-}
655 655
656#ifdef VERSION_lens 656#ifdef USE_lens
657message :: (Functor f, HasMessage x) => (Text -> f Text) -> (x -> f x) 657message :: (Functor f, HasMessage x) => (Text -> f Text) -> (x -> f x)
658message = lens getMessage setMessage 658message = lens getMessage setMessage
659#endif 659#endif
@@ -675,7 +675,7 @@ instance HasName CryptoMessage where
675 setName _ _ = error "setName on CryptoMessage without name field." 675 setName _ _ = error "setName on CryptoMessage without name field."
676-} 676-}
677 677
678#ifdef VERSION_lens 678#ifdef USE_lens
679name :: (Functor f, HasTitle x) => (Text -> f Text) -> (x -> f x) 679name :: (Functor f, HasTitle x) => (Text -> f Text) -> (x -> f x)
680name = lens getTitle setTitle 680name = lens getTitle setTitle
681#endif 681#endif