On Base 4.11 use the provided <&>, fixes #53
This commit is contained in:
@@ -17,7 +17,6 @@ module Protolude (
|
|||||||
print,
|
print,
|
||||||
throwIO,
|
throwIO,
|
||||||
throwTo,
|
throwTo,
|
||||||
foreach, (<&>),
|
|
||||||
show,
|
show,
|
||||||
pass,
|
pass,
|
||||||
guarded,
|
guarded,
|
||||||
@@ -590,16 +589,6 @@ throwIO = liftIO . Control.Exception.throwIO
|
|||||||
throwTo :: (X.MonadIO m, Exception e) => ThreadId -> e -> m ()
|
throwTo :: (X.MonadIO m, Exception e) => ThreadId -> e -> m ()
|
||||||
throwTo tid e = liftIO (Control.Exception.throwTo tid e)
|
throwTo tid e = liftIO (Control.Exception.throwTo tid e)
|
||||||
|
|
||||||
foreach :: Functor f => f a -> (a -> b) -> f b
|
|
||||||
foreach = flip fmap
|
|
||||||
|
|
||||||
-- | Infix version of foreach.
|
|
||||||
--
|
|
||||||
-- @<&>@ is to '<$>' what '&' is to '$'.
|
|
||||||
infixl 4 <&>
|
|
||||||
(<&>) :: Functor f => f a -> (a -> b) -> f b
|
|
||||||
(<&>) = foreach
|
|
||||||
|
|
||||||
-- | Do nothing returning unit inside applicative.
|
-- | Do nothing returning unit inside applicative.
|
||||||
pass :: Applicative f => f ()
|
pass :: Applicative f => f ()
|
||||||
pass = pure ()
|
pass = pure ()
|
||||||
|
|||||||
@@ -7,10 +7,17 @@ module Protolude.Functor (
|
|||||||
($>),
|
($>),
|
||||||
(<$>),
|
(<$>),
|
||||||
(<<$>>),
|
(<<$>>),
|
||||||
|
(<&>),
|
||||||
void,
|
void,
|
||||||
|
foreach,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Function ((.))
|
import Data.Function ((.))
|
||||||
|
import Data.Function (flip)
|
||||||
|
|
||||||
|
#if MIN_VERSION_base(4,11,0)
|
||||||
|
import Data.Functor ((<$>))
|
||||||
|
#endif
|
||||||
|
|
||||||
#if MIN_VERSION_base(4,7,0)
|
#if MIN_VERSION_base(4,7,0)
|
||||||
import Data.Functor (
|
import Data.Functor (
|
||||||
@@ -25,7 +32,6 @@ import Data.Functor (
|
|||||||
, (<$>)
|
, (<$>)
|
||||||
)
|
)
|
||||||
|
|
||||||
import Data.Function (flip)
|
|
||||||
|
|
||||||
infixl 4 $>
|
infixl 4 $>
|
||||||
|
|
||||||
@@ -40,3 +46,16 @@ infixl 4 <<$>>
|
|||||||
|
|
||||||
(<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
|
(<<$>>) :: (Functor f, Functor g) => (a -> b) -> f (g a) -> f (g b)
|
||||||
(<<$>>) = fmap . fmap
|
(<<$>>) = fmap . fmap
|
||||||
|
|
||||||
|
foreach :: Functor f => f a -> (a -> b) -> f b
|
||||||
|
foreach = flip fmap
|
||||||
|
|
||||||
|
#if !MIN_VERSION_base(4,11,0)
|
||||||
|
-- | Infix version of foreach.
|
||||||
|
--
|
||||||
|
-- @<&>@ is to '<$>' what '&' is to '$'.
|
||||||
|
|
||||||
|
infixl 1 <&>
|
||||||
|
(<&>) :: Functor f => f a -> (a -> b) -> f b
|
||||||
|
(<&>) = foreach
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user