diff options
Diffstat (limited to 'Presence/ControlMaybe.hs')
-rw-r--r-- | Presence/ControlMaybe.hs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/Presence/ControlMaybe.hs b/Presence/ControlMaybe.hs index 4d9d713f..c98a6fb9 100644 --- a/Presence/ControlMaybe.hs +++ b/Presence/ControlMaybe.hs | |||
@@ -1,9 +1,14 @@ | |||
1 | {-# LANGUAGE CPP #-} | ||
1 | {-# LANGUAGE ScopedTypeVariables #-} | 2 | {-# LANGUAGE ScopedTypeVariables #-} |
2 | module ControlMaybe where | 3 | module ControlMaybe |
4 | ( module ControlMaybe | ||
5 | , module Data.Functor | ||
6 | ) where | ||
3 | 7 | ||
4 | -- import GHC.IO.Exception (IOException(..)) | 8 | -- import GHC.IO.Exception (IOException(..)) |
5 | import Control.Monad | 9 | import Control.Monad |
6 | import Control.Exception as Exception (IOException(..),catch) | 10 | import Control.Exception as Exception (IOException(..),catch) |
11 | import Data.Functor | ||
7 | import System.IO.Error | 12 | import System.IO.Error |
8 | 13 | ||
9 | 14 | ||
@@ -29,3 +34,32 @@ handleIO_ catcher body = catchIOError body (\_ -> catcher) | |||
29 | handleIO :: (IOError -> IO a) -> IO a -> IO a | 34 | handleIO :: (IOError -> IO a) -> IO a -> IO a |
30 | handleIO catcher body = catchIOError body catcher | 35 | handleIO catcher body = catchIOError body catcher |
31 | {-# INLINE handleIO #-} | 36 | {-# INLINE handleIO #-} |
37 | |||
38 | #if !MIN_VERSION_base(4,11,0) | ||
39 | -- | Flipped version of '<$>'. | ||
40 | -- | ||
41 | -- @ | ||
42 | -- ('<&>') = 'flip' 'fmap' | ||
43 | -- @ | ||
44 | -- | ||
45 | -- @since 4.11.0.0 | ||
46 | -- | ||
47 | -- ==== __Examples__ | ||
48 | -- Apply @(+1)@ to a list, a 'Data.Maybe.Just' and a 'Data.Either.Right': | ||
49 | -- | ||
50 | -- >>> Just 2 <&> (+1) | ||
51 | -- Just 3 | ||
52 | -- | ||
53 | -- >>> [1,2,3] <&> (+1) | ||
54 | -- [2,3,4] | ||
55 | -- | ||
56 | -- >>> Right 3 <&> (+1) | ||
57 | -- Right 4 | ||
58 | -- | ||
59 | (<&>) :: Functor f => f a -> (a -> b) -> f b | ||
60 | as <&> f = f <$> as | ||
61 | |||
62 | infixl 1 <&> | ||
63 | #endif | ||
64 | |||
65 | |||