calculator 0.2.0.1 → 0.2.0.2
raw patch · 4 files changed
+16/−15 lines, 4 files
Files
- calculator.cabal +1/−1
- src/Calculator/Evaluator/Base.hs +2/−3
- src/Calculator/Help.hs +9/−9
- src/Main.hs +4/−2
calculator.cabal view
@@ -1,5 +1,5 @@ name: calculator-version: 0.2.0.1+version: 0.2.0.2 synopsis: A calculator repl. description: A calculator repl that processes mathematical expressions. Does basic arithmetic, and provides pre-defined basic mathematical functions.
src/Calculator/Evaluator/Base.hs view
@@ -10,7 +10,7 @@ -------------------------------------------------------------------------------- import Control.Applicative ((<*))--- import Data.List (nub)+import Data.List (nub) import Text.ParserCombinators.Parsec (eof, parse) --------------------------------------------------------------------------------@@ -26,8 +26,7 @@ result e = case e of Left (Constant c) -> Left $ " == " ++ show c--- Left (Message x) -> Left . init . unlines . map (" !! " ++ ) . nub $ x- Left (Message x) -> Left . init . unlines . map (" -!- " ++ ) $ x+ Left (Message x) -> Left . init . unlines . map (" -!- " ++ ) . nub $ x Right b -> Right b Left _ -> Left " ~~ Erroneous Result ~~"
src/Calculator/Help.hs view
@@ -2,7 +2,9 @@ -------------------------------------------------------------------------------- -import Calculator.Prim.Definitions (binaryOps, defFuns, defVars)+import Calculator.Color (bold)+import Calculator.Prim.Definitions (binaryOps, defFuns, defVars,+ unaryOps) -------------------------------------------------------------------------------- @@ -11,19 +13,17 @@ -------------------------------------------------------------------------------- help :: [String]-help = [ "Commands:"+help = [ bold "Commands:" , " :var x=pi -- Binds x to pi" , " :func f(x)=x+1 -- Binds f(x) to \"x + 1\""- , " :func f(x,y)=x+y -- Binds f(x) to \"x + 1\""+ , " :func f(x,y)=x+y -- Binds f(x) to \"x + y\"" , " :reset -- Reset variable and function bindings" , " :show -- Display all variable bindings" , " :? or :help -- Display this help message"- , ""- , "Supported Operations: " ++ intersperse ' ' (map fst binaryOps)- , ""- , "Pre-defined variables: " ++ intercalate ", " (map fst defVars)- , ""- , "Provided Functions: "+ , bold "Unary Operators: " ++ intersperse ' ' (map fst unaryOps)+ , bold "Binary Operators: " ++ intersperse ' ' (map fst binaryOps)+ , bold "Pre-defined variables: " ++ intercalate ", " (map fst defVars)+ , bold "Provided Functions: " , " " ++ intercalate ", " (map fst defFuns) ]
src/Main.hs view
@@ -6,6 +6,7 @@ -------------------------------------------------------------------------------- +import Calculator.Color (Color (..), bold, color) import Calculator.Evaluator.Base (evaluate) import Calculator.Prim.Bindings (Bindings) import Calculator.Prim.Definitions (defBinds)@@ -23,7 +24,7 @@ repl :: Bindings -> Repl () repl b = do- input <- getInputLine "calc> "+ input <- getInputLine $ color Red True "calc> " case input of Nothing -> return () Just inp -> case evaluate b inp of@@ -38,6 +39,7 @@ ++ showVersion version ++ ". Use :? for help." runInputT defaultSettings (repl defBinds)- putStrLn "Please report issues at: github.com/sumitsahrawat/calculator/issues"+ putStrLn $ "Please report issues at: " +++ bold "https://github.com/sumitsahrawat/calculator/issues" --------------------------------------------------------------------------------