diff options
author | Simon Jakobi <simon.jakobi@gmail.com> | 2019-05-29 17:20:41 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-05-31 02:02:33 -0400 |
commit | 495a65cbc48d5209f30fd4248fc11ab06b05d4c3 (patch) | |
tree | e35bf508bd76a6b0b9b97a751335f2a05a41186b | |
parent | 0c6f7f7eb94f80d3ed74a382af8a3294d070e740 (diff) | |
download | haskell-495a65cbc48d5209f30fd4248fc11ab06b05d4c3.tar.gz |
Implement (Functor.<$) for Data.Functor.{Compose,Product,Sum}
This allows us to make use of the (<$) implementations of the
underlying functors.
-rw-r--r-- | libraries/base/Data/Functor/Compose.hs | 1 | ||||
-rw-r--r-- | libraries/base/Data/Functor/Product.hs | 1 | ||||
-rw-r--r-- | libraries/base/Data/Functor/Sum.hs | 3 |
3 files changed, 5 insertions, 0 deletions
diff --git a/libraries/base/Data/Functor/Compose.hs b/libraries/base/Data/Functor/Compose.hs index 44570e1b41..d8369ebc05 100644 --- a/libraries/base/Data/Functor/Compose.hs +++ b/libraries/base/Data/Functor/Compose.hs @@ -100,6 +100,7 @@ instance (Show1 f, Show1 g, Show a) => Show (Compose f g a) where -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Compose f g) where fmap f (Compose x) = Compose (fmap (fmap f) x) + a <$ (Compose x) = Compose (fmap (a <$) x) -- | @since 4.9.0.0 instance (Foldable f, Foldable g) => Foldable (Compose f g) where diff --git a/libraries/base/Data/Functor/Product.hs b/libraries/base/Data/Functor/Product.hs index 8ed983b077..a3678e910e 100644 --- a/libraries/base/Data/Functor/Product.hs +++ b/libraries/base/Data/Functor/Product.hs @@ -81,6 +81,7 @@ instance (Show1 f, Show1 g, Show a) => Show (Product f g a) where -- | @since 4.9.0.0 instance (Functor f, Functor g) => Functor (Product f g) where fmap f (Pair x y) = Pair (fmap f x) (fmap f y) + a <$ (Pair x y) = Pair (a <$ x) (a <$ y) -- | @since 4.9.0.0 instance (Foldable f, Foldable g) => Foldable (Product f g) where diff --git a/libraries/base/Data/Functor/Sum.hs b/libraries/base/Data/Functor/Sum.hs index 337db02eee..f7d6178a2b 100644 --- a/libraries/base/Data/Functor/Sum.hs +++ b/libraries/base/Data/Functor/Sum.hs @@ -85,6 +85,9 @@ instance (Functor f, Functor g) => Functor (Sum f g) where fmap f (InL x) = InL (fmap f x) fmap f (InR y) = InR (fmap f y) + a <$ (InL x) = InL (a <$ x) + a <$ (InR y) = InR (a <$ y) + -- | @since 4.9.0.0 instance (Foldable f, Foldable g) => Foldable (Sum f g) where foldMap f (InL x) = foldMap f x |