Skip to content
Snippets Groups Projects
Commit df626f00 authored by Tobias Haslop's avatar Tobias Haslop Committed by Marge Bot
Browse files

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.
parent 30baac7a
No related branches found
No related tags found
No related merge requests found
......@@ -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 #-}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment