KWYCFMDQDUU3DLMJ5AOQC7ARBMYWQJG67WL27PMKGUSWHP7YBWTQC
DYEZ6CABMQQZD5GZR2DPR7NTHQH3GVT2ZI5ALX2YMEDWPS3YRNKQC
C5YXBVXHVYE5WZMMRMYFKJFXNRDVFZUQOZB27TZIMPOIEFWBWUPAC
B2JWXIEPCMVVITDJDR2SACY4VHITXGH7ZM6A5RWN6E7OKTO43TUAC
UJSPCZEQ5H5RKBLFM2SEJJTSKANJ7NKSM7DDWDWQ743ZPHMECROQC
R3GV7TM2HTCXTHWA76FZK6JJRSXCPRPXHV7FKMWXPQ2W2RIOTXEQC
import Control.Monad.Except (ExceptT, MonadError, runExceptT, throwError)
import Control.Monad.Except (ExceptT, MonadError, runExceptT,
throwError)
import Control.Monad.Except (ExceptT, MonadError, liftEither, runExceptT, throwError)
import Control.Monad.Except (ExceptT, MonadError, liftEither,
runExceptT, throwError)
import GHC.IO.Exception (IOErrorType (UserError), IOException (..))
import GHC.IO.Exception (IOErrorType (UserError),
IOException (..))
handleError = putStrLn
handleError = putStrLn . ("error: " ++)
liftIO $ withFile filename ReadMode (ByteStringLazy.hGetContents >=> printContent)
liftIO $ withFile filename ReadMode
(ByteStringLazy.hGetContents >=> printContent)
result <- liftIO $ withFile filename ReadMode (ByteStringLazy.hGetContents >=> tryJust catchError . printContent)
result <- liftIO $ withFile filename ReadMode
(ByteStringLazy.hGetContents
>=> tryJust catchError . printContent)
liftEither result where catchError e = case ioe_type e of UserError -> Just $ ioe_description e _ -> Nothing
liftEither result
where
catchError e = case ioe_type e of
UserError -> Just $ ioe_description e
_ -> Nothing