summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Crypto
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2017-11-04 03:45:21 +0000
committerJames Crayne <jim.crayne@gmail.com>2017-11-19 23:40:12 +0000
commit98c5eb996be5a3d015a46ed71c8db771deb53c0a (patch)
tree554646caf26ebfd6c54cbf0a65a67593e5a2ff3a /src/Network/Tox/Crypto
parentae2d321f380d4c3b3d967533693a1499f8d15a13 (diff)
minor code cleaning
Diffstat (limited to 'src/Network/Tox/Crypto')
-rw-r--r--src/Network/Tox/Crypto/Transport.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs
index 21100c86..386c2766 100644
--- a/src/Network/Tox/Crypto/Transport.hs
+++ b/src/Network/Tox/Crypto/Transport.hs
@@ -420,7 +420,7 @@ class AsWord16 a where
420 toWord16 :: a -> Word16 420 toWord16 :: a -> Word16
421 fromWord16 :: Word16 -> a 421 fromWord16 :: Word16 -> a
422 422
423toEnum8 ::Enum a => Word8 -> a 423toEnum8 :: (Enum a, Integral word8) => word8 -> a
424toEnum8 = toEnum . fromIntegral 424toEnum8 = toEnum . fromIntegral
425fromEnum8 :: Enum a => a -> Word8 425fromEnum8 :: Enum a => a -> Word8
426fromEnum8 = fromIntegral . fromEnum 426fromEnum8 = fromIntegral . fromEnum
@@ -435,9 +435,9 @@ fromEnum16 = fromIntegral . fromEnum
435-- (at least one bit set in high byte means extended, if none but the g flag and possibly l flag, assume default grp extension) 435-- (at least one bit set in high byte means extended, if none but the g flag and possibly l flag, assume default grp extension)
436instance AsWord16 MessageType where 436instance AsWord16 MessageType where
437 toWord16 (Msg msgID) = fromIntegral (fromIntegral (fromEnum16 msgID) :: Word8) 437 toWord16 (Msg msgID) = fromIntegral (fromIntegral (fromEnum16 msgID) :: Word8)
438 toWord16 (GrpMsg lsy msgName) = 512 + 256 * (fromEnum16 lsy) + fromIntegral (fromIntegral (fromEnum msgName) :: Word8) 438 toWord16 (GrpMsg lsy msgName) = 512 + 256 * (fromEnum16 lsy) + fromIntegral (fromEnum8 msgName)
439 fromWord16 x | x < 256 = Msg (toEnum $ fromIntegral x) 439 fromWord16 x | x < 256 = Msg (toEnum $ fromIntegral x)
440 fromWord16 x | x < 1024, x .|. 0x0200 == 0x0200 = GrpMsg (toEnum8 (fromIntegral ((x - 512) `div` 256))) (toEnum8 (fromIntegral x :: Word8)) 440 fromWord16 x | x < 1024, x .|. 0x0200 == 0x0200 = GrpMsg (toEnum8 ((x - 512) `div` 256)) (toEnum8 x)
441 fromWord16 x = error "Not clear how to convert Word16 to MessageType" 441 fromWord16 x = error "Not clear how to convert Word16 to MessageType"
442 442
443word16 :: (Functor f, AsWord16 x) => (Word16 -> f Word16) -> (x -> f x) 443word16 :: (Functor f, AsWord16 x) => (Word16 -> f Word16) -> (x -> f x)