simplify
This commit is contained in:
parent
184a69171d
commit
b06336fa3a
1 changed files with 1 additions and 4 deletions
|
@ -25,10 +25,7 @@ catchDefaultIO a def = catchIO a (const $ return def)
|
||||||
|
|
||||||
{- Catches IO errors and returns the error message. -}
|
{- Catches IO errors and returns the error message. -}
|
||||||
catchMsgIO :: IO a -> IO (Either String a)
|
catchMsgIO :: IO a -> IO (Either String a)
|
||||||
catchMsgIO a = dispatch <$> tryIO a
|
catchMsgIO a = either (Left . show) Right <$> tryIO a
|
||||||
where
|
|
||||||
dispatch (Left e) = Left $ show e
|
|
||||||
dispatch (Right v) = Right v
|
|
||||||
|
|
||||||
{- catch specialized for IO errors only -}
|
{- catch specialized for IO errors only -}
|
||||||
catchIO :: IO a -> (IOException -> IO a) -> IO a
|
catchIO :: IO a -> (IOException -> IO a) -> IO a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue