diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Data/BEncode.hs | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/Data/BEncode.hs b/src/Data/BEncode.hs index 37c84c7..402e8b3 100644 --- a/src/Data/BEncode.hs +++ b/src/Data/BEncode.hs | |||
@@ -436,18 +436,45 @@ instance BEncodable Word where | |||
436 | fromBEncode = fromBEncodeIntegral | 436 | fromBEncode = fromBEncodeIntegral |
437 | {-# INLINE fromBEncode #-} | 437 | {-# INLINE fromBEncode #-} |
438 | 438 | ||
439 | {-------------------------------------------------------------------- | 439 | instance BEncodable Int8 where |
440 | -- Derived instances | 440 | toBEncode = toBEncodeIntegral |
441 | --------------------------------------------------------------------} | 441 | {-# INLINE toBEncode #-} |
442 | |||
443 | fromBEncode = fromBEncodeIntegral | ||
444 | {-# INLINE fromBEncode #-} | ||
445 | |||
446 | instance BEncodable Int16 where | ||
447 | toBEncode = toBEncodeIntegral | ||
448 | {-# INLINE toBEncode #-} | ||
449 | |||
450 | fromBEncode = fromBEncodeIntegral | ||
451 | {-# INLINE fromBEncode #-} | ||
452 | |||
453 | instance BEncodable Int32 where | ||
454 | toBEncode = toBEncodeIntegral | ||
455 | {-# INLINE toBEncode #-} | ||
456 | |||
457 | fromBEncode = fromBEncodeIntegral | ||
458 | {-# INLINE fromBEncode #-} | ||
459 | |||
460 | instance BEncodable Int64 where | ||
461 | toBEncode = toBEncodeIntegral | ||
462 | {-# INLINE toBEncode #-} | ||
463 | |||
464 | fromBEncode = fromBEncodeIntegral | ||
465 | {-# INLINE fromBEncode #-} | ||
442 | 466 | ||
443 | instance BEncodable Int where | 467 | instance BEncodable Int where |
444 | toBEncode = BInteger . fromIntegral | 468 | toBEncode = toBEncodeIntegral |
445 | {-# INLINE toBEncode #-} | 469 | {-# INLINE toBEncode #-} |
446 | 470 | ||
447 | fromBEncode (BInteger i) = Right (fromIntegral i) | 471 | fromBEncode = fromBEncodeIntegral |
448 | fromBEncode _ = decodingError "Int" | ||
449 | {-# INLINE fromBEncode #-} | 472 | {-# INLINE fromBEncode #-} |
450 | 473 | ||
474 | {-------------------------------------------------------------------- | ||
475 | -- Derived instances | ||
476 | --------------------------------------------------------------------} | ||
477 | |||
451 | instance BEncodable Bool where | 478 | instance BEncodable Bool where |
452 | toBEncode = toBEncode . fromEnum | 479 | toBEncode = toBEncode . fromEnum |
453 | {-# INLINE toBEncode #-} | 480 | {-# INLINE toBEncode #-} |