summaryrefslogtreecommitdiff
path: root/Presence/ControlMaybe.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2018-06-21 01:26:58 -0400
committerjoe <joe@jerkface.net>2018-06-21 02:56:33 -0400
commit8cdc2de72ebe8945ce4b9f7fe8890970c34135a1 (patch)
tree99d8cbbaa46f089716f101058d0442b28f762bd8 /Presence/ControlMaybe.hs
parent458c7a99e07300cde99826f825c3d0d6a7eab298 (diff)
Avoid awkward "flip (maybe ...)" pattern.
Diffstat (limited to 'Presence/ControlMaybe.hs')
-rw-r--r--Presence/ControlMaybe.hs36
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 #-}
2module ControlMaybe where 3module ControlMaybe
4 ( module ControlMaybe
5 , module Data.Functor
6 ) where
3 7
4-- import GHC.IO.Exception (IOException(..)) 8-- import GHC.IO.Exception (IOException(..))
5import Control.Monad 9import Control.Monad
6import Control.Exception as Exception (IOException(..),catch) 10import Control.Exception as Exception (IOException(..),catch)
11import Data.Functor
7import System.IO.Error 12import System.IO.Error
8 13
9 14
@@ -29,3 +34,32 @@ handleIO_ catcher body = catchIOError body (\_ -> catcher)
29handleIO :: (IOError -> IO a) -> IO a -> IO a 34handleIO :: (IOError -> IO a) -> IO a -> IO a
30handleIO catcher body = catchIOError body catcher 35handleIO 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
60as <&> f = f <$> as
61
62infixl 1 <&>
63#endif
64
65