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

Modulefirst-class-families-0.8.1.0Haskell2010

Fcf.Class.Bifunctor

Bifunctors.

Bifunctors are "two-argument functors".

This module is the type-level equivalent of Data.Bifunctor.

  • 3 types
datadata Bimap (c :: a -> Exp a') (d :: b -> Exp b') (e :: f a b) (g :: f a' b')
#

Type-level bimap.

Example
Example2 expressions
data Example where Ex :: a -> Example  -- Hide the type of examples to avoid brittleness in different GHC versions:kind! Ex (Eval (Bimap ((+) 1) (Flip (-) 1) '(2, 4)) :: (Natural, Natural))Ex (Eval (Bimap ((+) 1) (Flip (-) 1) '(2, 4)) :: (Natural, Natural)) :: Example= Ex '(3, 3)
Instances3Eval
  • type Eval (Bimap f g '(x, y)) = '(Eval (f x), Eval (g y))Defined in first-class-families-0.8.1.0 · Fcf.Class.Bifunctor
  • type Eval (Bimap f g ('Left x)) = 'Left (Eval (f x))Defined in first-class-families-0.8.1.0 · Fcf.Class.Bifunctor
  • type Eval (Bimap f g ('Right y)) = 'Right (Eval (g y))Defined in first-class-families-0.8.1.0 · Fcf.Class.Bifunctor
datadata First (d :: a -> Exp b) (e :: f a c) (g :: f b c)
#

Type-level first. Apply a function along the first parameter of a bifunctor.

Example
Example1 expression
:kind! Eval (First ((+) 1) '(3,"a"))Eval (First ((+) 1) '(3,"a")) :: (Natural, Symbol)= '(4, "a")
Instances1Eval
datadata Second (b :: c -> Exp d) (e :: f a c) (g :: f a d)
#

Type-level second. Apply a function along the second parameter of a bifunctor.

This is generally equivalent to Data.Functor.Map.

Example
Example1 expression
:kind! Eval (Second ((+) 1) '("a",3))Eval (Second ((+) 1) '("a",3)) :: (Symbol, Natural)= '("a", 4)
Instances1Eval