{-# LANGUAGE CPP, NoImplicitPrelude #-}
module Data.Functor.Compat (
  module Base
, Functor(..)
, ($>)
, void
, (<&>)
, unzip
) where
import Data.Functor as Base

#if !(MIN_VERSION_base(4,7,0))
import Control.Monad.Compat (void)
import Data.Function (flip)
#endif

#if !(MIN_VERSION_base(4,19,0))
import Data.Tuple (fst, snd)
#endif

#if !(MIN_VERSION_base(4,7,0))
infixl 4 $>

-- | Flipped version of '$>'.
--
-- /Since: 4.7.0.0/
($>) :: Functor f => f a -> b -> f b
($>) = flip (<$)
#endif

#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

#if !(MIN_VERSION_base(4,19,0))
-- | Generalization of @Data.List.@'Data.List.unzip'.
--
-- /Since: 4.19.0.0/
unzip :: Functor f => f (a, b) -> (f a, f b)
unzip :: forall (f :: * -> *) a b. Functor f => f (a, b) -> (f a, f b)
unzip f (a, b)
xs = ((a, b) -> a
forall a b. (a, b) -> a
fst ((a, b) -> a) -> f (a, b) -> f a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (a, b)
xs, (a, b) -> b
forall a b. (a, b) -> b
snd ((a, b) -> b) -> f (a, b) -> f b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (a, b)
xs)
#endif