From: Ramakrishnan Muthukrishnan Date: Wed, 4 Feb 2015 11:05:24 +0000 (+0530) Subject: rearrange and refactor code for readability and comprehension. X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/biz/(%5B%5E?a=commitdiff_plain;h=5f175f3c153c64c3cf7e748cbe6a9a771209b276;p=functorrent.git rearrange and refactor code for readability and comprehension. --- diff --git a/src/Bencode.hs b/src/Bencode.hs index 1fb2a31..0da372b 100644 --- a/src/Bencode.hs +++ b/src/Bencode.hs @@ -60,11 +60,10 @@ bencInt = do _ <- spaces where numbers = do d' <- (char '-' <|> digit) ds' <- many digit parseNumber d' ds' - parseNumber '0' [] = return ['0'] + parseNumber '0' [] = return "0" + parseNumber '0' _ = unexpected "numbers cannot be left-padded with zeros" parseNumber '-' [] = unexpected "sign without any digits" - parseNumber '0' ds'' = unexpected "numbers cannot be left-padded with zeros" - parseNumber '-' (d'':ds'') | d'' == '0' = unexpected "numbers cannot be left-padded with zeros" - parseNumber '-' ds'' = return ('-':ds'') + parseNumber '-' (d'':_) | d'' == '0' = unexpected "numbers cannot be left-padded with zeros" parseNumber d'' ds'' = return (d'':ds'') bencParser :: ParsecBS.Parser BVal