diff --git a/libraries/base/src/Data/Bifunctor.hs b/libraries/base/src/Data/Bifunctor.hs index d01917ffaa75c9e0cb58ec1419c33aa22e7550dc..e7a776cd995b7b9194d781ec98c2fdf27c25bbc0 100644 --- a/libraries/base/src/Data/Bifunctor.hs +++ b/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@. 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 #-}