[Git][ghc/ghc][master] Document that Bifunctor instances for tuples are lawful only up to laziness
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Sun Dec 11 17:27:20 UTC 2022
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
bfd7c1e6 by Bodigrim at 2022-12-11T12:26:55-05:00
Document that Bifunctor instances for tuples are lawful only up to laziness
- - - - -
1 changed file:
- libraries/base/Data/Bifunctor.hs
Changes:
=====================================
libraries/base/Data/Bifunctor.hs
=====================================
@@ -120,8 +120,17 @@ class (forall a. Functor (p a)) => Bifunctor p where
second = bimap id
-
--- | @since 4.8.0.0
+-- | Class laws for tuples hold only up to laziness. Both
+-- 'first' 'id' and 'second' 'id' are lazier than 'id' (and 'fmap' 'id'):
+--
+-- >>> first id (undefined :: (Int, Word)) `seq` ()
+-- ()
+-- >>> second id (undefined :: (Int, Word)) `seq` ()
+-- ()
+-- >>> id (undefined :: (Int, Word)) `seq` ()
+-- *** Exception: Prelude.undefined
+--
+-- @since 4.8.0.0
instance Bifunctor (,) where
bimap f g ~(a, b) = (f a, g b)
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bfd7c1e653c207dd5dea599f16ee4afad03f2ea5
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/bfd7c1e653c207dd5dea599f16ee4afad03f2ea5
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/20221211/cee006f9/attachment-0001.html>
More information about the ghc-commits
mailing list