putStrLn $ "You need to " ++ t
printTask (Wish t) = putStrLn $ "You want to " ++ t
act :: [Task] -> Int -> IO [Task]
act t 2 = do
mapM_ printTask t
return t
act t 1 = do
putStr "Enter name of the task: "
name <- readLn :: String
putStr "Enter type of the note (1 - necessary, 2 - wish): "
return t
act t _ = do
putStrLn "Wrong usage."
return t
-- typ <- readLn
-- if typ == 1 then
-- else
loop :: IO [Task] -> IO ()
loop t = do
putStrLn "What do you want to do?"
putStrLn "1 - Add task"
putStrLn "2 - List tasks"
putStrLn "3 - Get plan of the day and exit the program"
var <- readLn
tasks <- t
loop (act tasks var)
main :: IO ()
main = do
let t = [] :: [Task]
loop (return t)
~/coding/plan/app/ 2
└╴ Main.hs 2
├╴E • Couldn't match type: IO a0
│ with: [Char]
│ Expected: String
│ Actual: IO a0
│ • In a stmt of a 'do' block: name <- readLn :: String
│ In the expression:
│ do putStr "Enter name of the task: "
│ name <- readLn :: String
│ putStr "Enter type of the note (1 - necessary, 2 - wish): "
│ return t
│ In an equation for ‘act’:
│ act t 1
│ = do putStr "Enter name of the task: "
│ name <- readLn :: String
│ putStr "Enter type of the note (1 - necessary, 2 - wish): "
│ .... typecheck (-Wdeferred-type-errors) [13, 11]
└╴W Defined but not used: ‘name’ typecheck (-Wunused-matches) [13, 3]
что делать в такой ситуации?
чтение ошибки не помогает =(
В ошибке написано, что не получается сопостивить некое IO a0 и String (т.е. [Char]) и написано в ошибке. Надо или readLn :: IO String, или readLn @String
Обсуждают сегодня