module Main where -------------------------------------------------------------------------------- import Paths_calculator (version) -------------------------------------------------------------------------------- import Calculator.Evaluator.Base (evaluate) import Calculator.Prim.Bindings (Bindings) import Calculator.Prim.Definitions (defBinds) -------------------------------------------------------------------------------- import Data.Version (showVersion) import System.Console.Haskeline -------------------------------------------------------------------------------- type Repl a = InputT IO a -------------------------------------------------------------------------------- repl :: Bindings -> Repl () repl b = do input <- getInputLine "calc> " case input of Nothing -> return () Just inp -> case evaluate b inp of Left s -> outputStrLn s >> repl b Right b' -> repl b' -------------------------------------------------------------------------------- main :: IO () main = do putStrLn $ "calculator, version " ++ showVersion version ++ ". Use :? for help." runInputT defaultSettings (repl defBinds) putStrLn "Please report issues at: github.com/sumitsahrawat/calculator/issues" --------------------------------------------------------------------------------