Я пытаюсь прочитать файл на Haskell с перехватом исключений, но не могу работать.Код выглядит так:
module Main where
import System.Environment
import System.IO
import System.Exit
main = do
x:xs <- getArgs
case length(x:xs) of
2 -> do catch (readFile x)
(\_ -> do putStrLn ("Error on reading file: " ++ x)
getLine
exitWith ExitSuccess)
_ -> do putStrLn ("Run this way: ./projekt inputFile RE") >>
exitFailure
И я получаю эту ошибку:
Couldn't match expected type `IO String
-> (ExitCode -> IO a)
-> ExitCode
-> IO String'
against inferred type `IO ()'
In the expression:
putStrLn
("Error on reading file: " ++ x) getLine exitWith ExitSuccess
In the expression:
do { putStrLn
("Error on reading file: " ++ x) getLine exitWith ExitSuccess }
In the second argument of `catch', namely
`(\ _ -> do { putStrLn
("Error on reading file: " ++ x) getLine exitWith ExitSuccess })'
Можете ли вы дать мне подсказку?Спасибо