[Git][ghc/ghc][master] Implement (Functor.<$) for Data.Functor.{Compose,Product,Sum}
Marge Bot
gitlab at gitlab.haskell.org
Fri May 31 06:02:38 UTC 2019
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
495a65cb by Simon Jakobi at 2019-05-31T06:02:33Z
Implement (Functor.<$) for Data.Functor.{Compose,Product,Sum}
This allows us to make use of the (<$) implementations of the
underlying functors.
- - - - -
3 changed files:
- libraries/base/Data/Functor/Compose.hs
- libraries/base/Data/Functor/Product.hs
- libraries/base/Data/Functor/Sum.hs
Changes:
=====================================
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
=====================================
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
=====================================
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
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/495a65cbc48d5209f30fd4248fc11ab06b05d4c3
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/commit/495a65cbc48d5209f30fd4248fc11ab06b05d4c3
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20190531/58377349/attachment-0001.html>
More information about the ghc-commits
mailing list