diff options
-rw-r--r-- | src/Data/BEncode.hs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Data/BEncode.hs b/src/Data/BEncode.hs index 4a80e47..80f0108 100644 --- a/src/Data/BEncode.hs +++ b/src/Data/BEncode.hs | |||
@@ -68,7 +68,7 @@ class BEncodable a where | |||
68 | -- bencoding = Iso (Right . toBencode) fromBEncode | 68 | -- bencoding = Iso (Right . toBencode) fromBEncode |
69 | 69 | ||
70 | decodingError :: String -> Result a | 70 | decodingError :: String -> Result a |
71 | decodingError s = Left ("fromBEncode: unable to match " ++ s) | 71 | decodingError s = Left ("fromBEncode: unable to decode " ++ s) |
72 | {-# INLINE decodingError #-} | 72 | {-# INLINE decodingError #-} |
73 | 73 | ||
74 | instance BEncodable BEncode where | 74 | instance BEncodable BEncode where |
@@ -182,7 +182,8 @@ reqKey d key | |||
182 | 182 | ||
183 | optKey :: BEncodable a => Map ByteString BEncode -> ByteString -> Result (Maybe a) | 183 | optKey :: BEncodable a => Map ByteString BEncode -> ByteString -> Result (Maybe a) |
184 | optKey d key | 184 | optKey d key |
185 | | Just b <- M.lookup key d = Just <$> fromBEncode b | 185 | | Just b <- M.lookup key d |
186 | , Right r <- fromBEncode b = return (Just r) | ||
186 | | otherwise = return Nothing | 187 | | otherwise = return Nothing |
187 | 188 | ||
188 | (>--) :: BEncodable a => Map ByteString BEncode -> ByteString -> Result a | 189 | (>--) :: BEncodable a => Map ByteString BEncode -> ByteString -> Result a |