summaryrefslogtreecommitdiff
path: root/ControlMaybe.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ControlMaybe.hs')
-rw-r--r--ControlMaybe.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/ControlMaybe.hs b/ControlMaybe.hs
index 69a38f7..659dab7 100644
--- a/ControlMaybe.hs
+++ b/ControlMaybe.hs
@@ -4,9 +4,12 @@ module ControlMaybe where
4-- import GHC.IO.Exception (IOException(..)) 4-- import GHC.IO.Exception (IOException(..))
5import Control.Exception as Exception (IOException(..),catch) 5import Control.Exception as Exception (IOException(..),catch)
6 6
7
8withJust :: Monad m => Maybe x -> (x -> m ()) -> m ()
7withJust (Just x) f = f x 9withJust (Just x) f = f x
8withJust Nothing f = return () 10withJust Nothing f = return ()
9 11
12whenJust :: Monad m => m (Maybe x) -> (x -> m ()) -> m ()
10whenJust acn f = do 13whenJust acn f = do
11 x <- acn 14 x <- acn
12 withJust x f 15 withJust x f
@@ -18,6 +21,9 @@ catchIO_ a h = Exception.catch a (\(_ :: IOException) -> h)
18catchIO :: IO a -> (IOException -> IO a) -> IO a 21catchIO :: IO a -> (IOException -> IO a) -> IO a
19catchIO body handler = Exception.catch body handler 22catchIO body handler = Exception.catch body handler
20 23
24handleIO_ :: IO a -> IO a -> IO a
21handleIO_ = flip catchIO_ 25handleIO_ = flip catchIO_
22handleIO = flip catchIO
23 26
27
28handleIO :: (IOException -> IO a) -> IO a -> IO a
29handleIO = flip catchIO