HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebifunctors-5.6.2Haskell2010

Data.Bifunctor.Biap

  • 1 type
  • Packagebifunctors-5.6.2
  • Exports1
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceBiap.hs
newtypenewtype Biap (bi :: Type -> Type -> Type) a b
#

Pointwise lifting of a class over two arguments, using Biapplicative.

Classes that can be lifted include Monoid, Num and Bounded. Each method of those classes can be defined as lifting themselves over each argument of Biapplicative.

mempty        = bipure mempty          mempty
minBound      = bipure minBound        minBound
maxBound      = bipure maxBound        maxBound
fromInteger n = bipure (fromInteger n) (fromInteger n)

negate = bimap negate negate

(+)  = biliftA2 (+)  (+)
(<>) = biliftA2 (<>) (<>)

Biap is to Biapplicative as Ap is to Applicative.

Biap can be used with DerivingVia to derive a numeric instance for pairs:

newtype Numpair a = Np (a, a)
 deriving (S.Semigroup, Monoid, Num, Bounded)
 via Biap (,) a a

Constructors

Instances29Generic1, Bifoldable, Bifunctor, Bitraversable, Eq2, Ord2, …