diff options
author | joe <joe@jerkface.net> | 2014-04-21 21:48:06 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2014-04-21 21:48:06 -0400 |
commit | a391d183e2f79ab942e1516e1875793cd1d5abcc (patch) | |
tree | f3c5223e8633d679a034d02feb8fd78841944dcd /ControlMaybe.hs | |
parent | 3737be4b3daf242ec13cdbc8100a751f5882a1a1 (diff) |
Some type signatures
Diffstat (limited to 'ControlMaybe.hs')
-rw-r--r-- | ControlMaybe.hs | 8 |
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(..)) |
5 | import Control.Exception as Exception (IOException(..),catch) | 5 | import Control.Exception as Exception (IOException(..),catch) |
6 | 6 | ||
7 | |||
8 | withJust :: Monad m => Maybe x -> (x -> m ()) -> m () | ||
7 | withJust (Just x) f = f x | 9 | withJust (Just x) f = f x |
8 | withJust Nothing f = return () | 10 | withJust Nothing f = return () |
9 | 11 | ||
12 | whenJust :: Monad m => m (Maybe x) -> (x -> m ()) -> m () | ||
10 | whenJust acn f = do | 13 | whenJust 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) | |||
18 | catchIO :: IO a -> (IOException -> IO a) -> IO a | 21 | catchIO :: IO a -> (IOException -> IO a) -> IO a |
19 | catchIO body handler = Exception.catch body handler | 22 | catchIO body handler = Exception.catch body handler |
20 | 23 | ||
24 | handleIO_ :: IO a -> IO a -> IO a | ||
21 | handleIO_ = flip catchIO_ | 25 | handleIO_ = flip catchIO_ |
22 | handleIO = flip catchIO | ||
23 | 26 | ||
27 | |||
28 | handleIO :: (IOException -> IO a) -> IO a -> IO a | ||
29 | handleIO = flip catchIO | ||