summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2013-02-28 20:29:39 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2013-02-28 20:29:39 +0000
commit445464513287f2f7b6a76974c4fcdf6cba2987d8 (patch)
tree31666d0968da10bf1e31ed1e50fcad0e4b4ddf1a
parent47d52a15ce9b2f03abb7ed676b031b340c4d5c72 (diff)
downloadcalculator-445464513287f2f7b6a76974c4fcdf6cba2987d8.tar.bz2
Parse negative integers too
-rw-r--r--calculator.hs3
1 files changed, 2 insertions, 1 deletions
diff --git a/calculator.hs b/calculator.hs
index ecdbff8..12f958e 100644
--- a/calculator.hs
+++ b/calculator.hs
@@ -3,8 +3,9 @@ import Text.Parsec.String
parseNumber :: Parser Int
parseNumber = do
+ neg <- (char '-' >> return "-") <|> (return "")
n' <- many1 $ oneOf "0123456789"
- return (read n')
+ return (read (neg ++ n'))
calculation :: Parser Int
calculation = do