diff options
Diffstat (limited to 'Presence/ControlMaybe.hs')
-rw-r--r-- | Presence/ControlMaybe.hs | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/Presence/ControlMaybe.hs b/Presence/ControlMaybe.hs deleted file mode 100644 index a101d667..00000000 --- a/Presence/ControlMaybe.hs +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | {-# LANGUAGE CPP #-} | ||
2 | {-# LANGUAGE ScopedTypeVariables #-} | ||
3 | module ControlMaybe | ||
4 | ( module ControlMaybe | ||
5 | , module Data.Functor | ||
6 | ) where | ||
7 | |||
8 | -- import GHC.IO.Exception (IOException(..)) | ||
9 | import Control.Monad | ||
10 | import Data.Functor | ||
11 | import System.IO.Error | ||
12 | |||
13 | |||
14 | -- forM_ with less polymorphism. | ||
15 | withJust :: Monad m => Maybe x -> (x -> m ()) -> m () | ||
16 | withJust m f = forM_ m f | ||
17 | {-# INLINE withJust #-} | ||
18 | |||
19 | whenJust :: Monad m => m (Maybe x) -> (x -> m ()) -> m () | ||
20 | whenJust acn f = acn >>= mapM_ f | ||
21 | {-# INLINE whenJust #-} | ||
22 | |||
23 | |||
24 | catchIO_ :: IO a -> IO a -> IO a | ||
25 | catchIO_ body catcher = catchIOError body (\_ -> catcher) | ||
26 | {-# INLINE catchIO_ #-} | ||
27 | |||
28 | handleIO_ :: IO a -> IO a -> IO a | ||
29 | handleIO_ catcher body = catchIOError body (\_ -> catcher) | ||
30 | {-# INLINE handleIO_ #-} | ||
31 | |||
32 | |||
33 | handleIO :: (IOError -> IO a) -> IO a -> IO a | ||
34 | handleIO catcher body = catchIOError body catcher | ||
35 | {-# INLINE handleIO #-} | ||
36 | |||
37 | #if !MIN_VERSION_base(4,11,0) | ||
38 | -- | Flipped version of '<$>'. | ||
39 | -- | ||
40 | -- @ | ||
41 | -- ('<&>') = 'flip' 'fmap' | ||
42 | -- @ | ||
43 | -- | ||
44 | -- @since 4.11.0.0 | ||
45 | -- | ||
46 | -- ==== __Examples__ | ||
47 | -- Apply @(+1)@ to a list, a 'Data.Maybe.Just' and a 'Data.Either.Right': | ||
48 | -- | ||
49 | -- >>> Just 2 <&> (+1) | ||
50 | -- Just 3 | ||
51 | -- | ||
52 | -- >>> [1,2,3] <&> (+1) | ||
53 | -- [2,3,4] | ||
54 | -- | ||
55 | -- >>> Right 3 <&> (+1) | ||
56 | -- Right 4 | ||
57 | -- | ||
58 | (<&>) :: Functor f => f a -> (a -> b) -> f b | ||
59 | as <&> f = f <$> as | ||
60 | |||
61 | infixl 1 <&> | ||
62 | #endif | ||
63 | |||
64 | |||