From 8cdc2de72ebe8945ce4b9f7fe8890970c34135a1 Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 21 Jun 2018 01:26:58 -0400 Subject: Avoid awkward "flip (maybe ...)" pattern. --- Presence/ControlMaybe.hs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'Presence/ControlMaybe.hs') 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 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE ScopedTypeVariables #-} -module ControlMaybe where +module ControlMaybe + ( module ControlMaybe + , module Data.Functor + ) where -- import GHC.IO.Exception (IOException(..)) import Control.Monad import Control.Exception as Exception (IOException(..),catch) +import Data.Functor import System.IO.Error @@ -29,3 +34,32 @@ handleIO_ catcher body = catchIOError body (\_ -> catcher) handleIO :: (IOError -> IO a) -> IO a -> IO a handleIO catcher body = catchIOError body catcher {-# INLINE handleIO #-} + +#if !MIN_VERSION_base(4,11,0) +-- | Flipped version of '<$>'. +-- +-- @ +-- ('<&>') = 'flip' 'fmap' +-- @ +-- +-- @since 4.11.0.0 +-- +-- ==== __Examples__ +-- Apply @(+1)@ to a list, a 'Data.Maybe.Just' and a 'Data.Either.Right': +-- +-- >>> Just 2 <&> (+1) +-- Just 3 +-- +-- >>> [1,2,3] <&> (+1) +-- [2,3,4] +-- +-- >>> Right 3 <&> (+1) +-- Right 4 +-- +(<&>) :: Functor f => f a -> (a -> b) -> f b +as <&> f = f <$> as + +infixl 1 <&> +#endif + + -- cgit v1.2.3