Первая версия Main, но пока с do-нотацией

This commit is contained in:
2024-12-08 20:00:12 +03:00
parent 1a45ec2330
commit 3692629264
4 changed files with 16 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
.stack-work/
*~
!task_part1.txt
!expressions.txt

View File

@@ -3,4 +3,10 @@ module Main (main) where
import Lib
main :: IO ()
main = putStrLn "temp"
main = do
putStrLn "Введите имя файла:"
fileName <- getLine
content <- readFile fileName
let expressions = lines content
putStrLn $ concatMap processExpression expressions

View File

@@ -0,0 +1,6 @@
100 * 100
40 + 30
50 / 2
5 / 2
62 - 32
78 - 500

View File

@@ -96,7 +96,7 @@ processExpression s = case runParser expression s of
show a ++ " " ++
operationToString op ++ " " ++
show b ++ " = " ++
show (calculateExpression (a, op, b))
show (calculateExpression (a, op, b)) ++ "\n"
_ -> err
where
err = error $ "Unable to parse the following expression: \"" ++ s ++ "\""