From 8e9896c5d03ba2362e5068151106f756f0a002a1 Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Fri, 29 Nov 2013 19:28:30 +0400 Subject: Remove byteStringToPeerId to simplify API --- src/Network/BitTorrent/Tracker/Message.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Network/BitTorrent/Tracker') diff --git a/src/Network/BitTorrent/Tracker/Message.hs b/src/Network/BitTorrent/Tracker/Message.hs index 046f7e57..9999d128 100644 --- a/src/Network/BitTorrent/Tracker/Message.hs +++ b/src/Network/BitTorrent/Tracker/Message.hs @@ -267,7 +267,7 @@ instance FromParam InfoHash where fromParam = either (const Nothing) pure . safeConvert instance FromParam PeerId where - fromParam = byteStringToPeerId + fromParam = either (const Nothing) pure . safeConvert instance FromParam Word32 where fromParam = readMaybe . BC.unpack @@ -282,9 +282,9 @@ instance FromParam PortNumber where fromParam bs = fromIntegral <$> (fromParam bs :: Maybe Word32) instance FromParam Event where - fromParam bs = case BC.uncons bs of - Nothing -> Nothing - Just (x, xs) -> readMaybe $ BC.unpack $ BC.cons (Char.toUpper x) xs + fromParam bs = do + (x, xs) <- BC.uncons bs + readMaybe $ BC.unpack $ BC.cons (Char.toUpper x) xs type Result = Either ParamParseFailure -- cgit v1.2.3