summaryrefslogtreecommitdiff
path: root/calculator.hs
blob: 775302273ba2bdc210c5cdef5eaf94d869b483de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import Text.Parsec
import Text.Parsec.String

calculation :: Parser Int
calculation = return undefined

calculate :: String -> String
calculate s =
  case ret of
    Left e -> "error: " ++ (show e)
    Right n -> "answer: " ++ (show n)
  where
    ret = parse calculation "" s

main :: IO ()
main = interact (unlines . (map calculate) . lines)