-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMain.hs
39 lines (31 loc) · 1006 Bytes
/
Main.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module Main where
import System.IO
import Proof
import ProofMinimizator
main :: IO ()
main = do task <- getLine
mainloop (fromTask . getTask $ task)
mainloop :: HalfProof -> IO ()
mainloop proof = do
ineof <- isEOF
if ineof
then if failure proof
then putStrLn incorrectString
else case minimizeProof . sortProof $ proof of
Nothing -> putStrLn incorrectString
Just p -> showProof p
else do ex <- getLine
case addExpression (getExpression ex) proof of
Nothing -> putStrLn incorrectString
Just newproof -> mainloop newproof
incorrectString = "Proof is incorrect"
showProof :: SortedProof -> IO ()
showProof sp = do
putStrLn . show $ (task sp)
listShower showExpression (length . expressions $ sp) (expressions sp)
listShower :: (a -> Int -> String) -> Int -> [a] -> IO ()
listShower _ _ [] = do
putStr ""
listShower f n (h:t) = do
listShower f (n - 1) t
putStrLn $ f h n