[Git][ghc/ghc][master] Elaborate on the quantified superclass of Bifunctor

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Nov 7 07:21:06 UTC 2023



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
df626f00 by Tobias Haslop at 2023-11-07T02:20:37-05:00
Elaborate on the quantified superclass of Bifunctor

This was requested in the comment
https://github.com/haskell/core-libraries-committee/issues/93#issuecomment-1597271700
for when Traversable becomes a superclass of Bitraversable, but similarly
applies to Functor/Bifunctor, which already are in a superclass relationship.

- - - - -


1 changed file:

- libraries/base/src/Data/Bifunctor.hs


Changes:

=====================================
libraries/base/src/Data/Bifunctor.hs
=====================================
@@ -39,9 +39,23 @@ import GHC.Generics ( K1(..) )
 -- Intuitively it is a bifunctor where both the first and second
 -- arguments are covariant.
 --
+-- The class definition of a 'Bifunctor' @p@ uses the
+-- [QuantifiedConstraints](https://downloads.haskell.org/ghc/latest/docs/users_guide/exts/quantified_constraints.html)
+-- language extension to quantify over the first type
+-- argument @a@ in its context. The context requires that @p a@
+-- must be a 'Functor' for all @a at . In other words a partially
+-- applied 'Bifunctor' must be a 'Functor'. This makes 'Functor' a
+-- superclass of 'Bifunctor' such that a function with a
+-- 'Bifunctor' constraint may use 'fmap' in its implementation.
+-- 'Functor' has been a quantified superclass of
+-- 'Bifunctor' since base-4.18.0.0.
+--
 -- You can define a 'Bifunctor' by either defining 'bimap' or by
--- defining both 'first' and 'second'. A partially applied 'Bifunctor'
--- must be a 'Functor' and the 'second' method must agree with 'fmap'.
+-- defining both 'first' and 'second'. The 'second' method must
+-- agree with 'fmap':
+--
+-- @'second' ≡ 'fmap'@
+--
 -- From this it follows that:
 --
 -- @'second' 'id' ≡ 'id'@
@@ -69,8 +83,6 @@ import GHC.Generics ( K1(..) )
 -- 'second' (f '.' g) ≡ 'second' f '.' 'second' g
 -- @
 --
--- Since 4.18.0.0 'Functor' is a superclass of 'Bifunctor.
---
 -- @since 4.8.0.0
 class (forall a. Functor (p a)) => Bifunctor p where
     {-# MINIMAL bimap | first, second #-}



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df626f008230fd55308d8c64d3879d7ec79b44df

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/df626f008230fd55308d8c64d3879d7ec79b44df
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/20231107/49a38a0d/attachment-0001.html>


More information about the ghc-commits mailing list