diff options
-rw-r--r-- | src/Network/Tox/Crypto/Transport.hs | 6 |
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 | ||
423 | toEnum8 ::Enum a => Word8 -> a | 423 | toEnum8 :: (Enum a, Integral word8) => word8 -> a |
424 | toEnum8 = toEnum . fromIntegral | 424 | toEnum8 = toEnum . fromIntegral |
425 | fromEnum8 :: Enum a => a -> Word8 | 425 | fromEnum8 :: Enum a => a -> Word8 |
426 | fromEnum8 = fromIntegral . fromEnum | 426 | fromEnum8 = 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) |
436 | instance AsWord16 MessageType where | 436 | instance 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 | ||
443 | word16 :: (Functor f, AsWord16 x) => (Word16 -> f Word16) -> (x -> f x) | 443 | word16 :: (Functor f, AsWord16 x) => (Word16 -> f Word16) -> (x -> f x) |