diff options
Diffstat (limited to 'src/Data')
-rw-r--r-- | src/Data/BEncode.hs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Data/BEncode.hs b/src/Data/BEncode.hs index f12d116..ebeed6e 100644 --- a/src/Data/BEncode.hs +++ b/src/Data/BEncode.hs | |||
@@ -648,14 +648,13 @@ fromDict _ _ = decodingError (show (typeOf inst)) | |||
648 | -- > ] | 648 | -- > ] |
649 | -- > ... | 649 | -- > ... |
650 | -- | 650 | -- |
651 | type Assoc = Maybe BPair | 651 | data Assoc = Some BKey BValue |
652 | 652 | | None | |
653 | type BPair = (BKey, BValue) | ||
654 | 653 | ||
655 | -- TODO better name | 654 | -- TODO better name |
656 | -- | Make required key value pair. | 655 | -- | Make required key value pair. |
657 | (.=!) :: BEncode a => BKey -> a -> Assoc | 656 | (.=!) :: BEncode a => BKey -> a -> Assoc |
658 | k .=! v = Just (k, toBEncode v) | 657 | k .=! v = Some k (toBEncode v) |
659 | {-# INLINE (.=!) #-} | 658 | {-# INLINE (.=!) #-} |
660 | 659 | ||
661 | infix 6 .=! | 660 | infix 6 .=! |
@@ -664,15 +663,15 @@ infix 6 .=! | |||
664 | -- appear in resulting bencoded dictionary. | 663 | -- appear in resulting bencoded dictionary. |
665 | -- | 664 | -- |
666 | (.=?) :: BEncode a => BKey -> Maybe a -> Assoc | 665 | (.=?) :: BEncode a => BKey -> Maybe a -> Assoc |
667 | _ .=? Nothing = Nothing | 666 | _ .=? Nothing = None |
668 | k .=? Just v = Just (k, toBEncode v) | 667 | k .=? Just v = Some k (toBEncode v) |
669 | {-# INLINE (.=?) #-} | 668 | {-# INLINE (.=?) #-} |
670 | 669 | ||
671 | infix 6 .=? | 670 | infix 6 .=? |
672 | 671 | ||
673 | (.:) :: Assoc -> BDict -> BDict | 672 | (.:) :: Assoc -> BDict -> BDict |
674 | Nothing .: d = d | 673 | None .: d = d |
675 | Just (k, v) .: d = Cons k v d | 674 | Some k v .: d = Cons k v d |
676 | {-# INLINE (.:) #-} | 675 | {-# INLINE (.:) #-} |
677 | 676 | ||
678 | infixr 5 .: | 677 | infixr 5 .: |