From a391d183e2f79ab942e1516e1875793cd1d5abcc Mon Sep 17 00:00:00 2001 From: joe Date: Mon, 21 Apr 2014 21:48:06 -0400 Subject: Some type signatures --- ControlMaybe.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'ControlMaybe.hs') 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 -- import GHC.IO.Exception (IOException(..)) import Control.Exception as Exception (IOException(..),catch) + +withJust :: Monad m => Maybe x -> (x -> m ()) -> m () withJust (Just x) f = f x withJust Nothing f = return () +whenJust :: Monad m => m (Maybe x) -> (x -> m ()) -> m () whenJust acn f = do x <- acn withJust x f @@ -18,6 +21,9 @@ catchIO_ a h = Exception.catch a (\(_ :: IOException) -> h) catchIO :: IO a -> (IOException -> IO a) -> IO a catchIO body handler = Exception.catch body handler +handleIO_ :: IO a -> IO a -> IO a handleIO_ = flip catchIO_ -handleIO = flip catchIO + +handleIO :: (IOException -> IO a) -> IO a -> IO a +handleIO = flip catchIO -- cgit v1.2.3