From 5f175f3c153c64c3cf7e748cbe6a9a771209b276 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Wed, 4 Feb 2015 16:35:24 +0530
Subject: [PATCH] rearrange and refactor code for readability and
 comprehension.

---
 src/Bencode.hs | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

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
-- 
2.45.2