first-class-families-0.8.0.1: First-class type families
Safe HaskellSafe-Inferred
LanguageHaskell2010

Fcf.Class.Bifunctor

Description

Bifunctors.

Bifunctors are "two-argument functors".

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

Synopsis

Documentation

data Bimap :: (a -> Exp a') -> (b -> Exp b') -> f a b -> Exp (f a' b') Source #

Type-level bimap.

>>> :kind! Eval (Bimap ((+) 1) (Flip (-) 1) '(2, 4))
Eval (Bimap ((+) 1) (Flip (-) 1) '(2, 4)) :: (Nat, Nat)
= '(3, 3)

Instances

Instances details
type Eval (Bimap f g ('Right y :: Either a b1) :: Either a' b2 -> Type) Source # 
Instance details

Defined in Fcf.Class.Bifunctor

type Eval (Bimap f g ('Right y :: Either a b1) :: Either a' b2 -> Type) = 'Right (Eval (g y)) :: Either a' b2
type Eval (Bimap f g ('Left x :: Either a1 b) :: Either a2 b' -> Type) Source # 
Instance details

Defined in Fcf.Class.Bifunctor

type Eval (Bimap f g ('Left x :: Either a1 b) :: Either a2 b' -> Type) = 'Left (Eval (f x)) :: Either a2 b'
type Eval (Bimap f g '(x, y) :: (k1, k2) -> Type) Source # 
Instance details

Defined in Fcf.Class.Bifunctor

type Eval (Bimap f g '(x, y) :: (k1, k2) -> Type) = '(Eval (f x), Eval (g y))

data First :: (a -> Exp b) -> f a c -> Exp (f b c) Source #

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

Example

Expand
>>> :kind! Eval (First ((+) 1) '(3,"a"))
Eval (First ((+) 1) '(3,"a")) :: (Nat, Symbol)
= '(4, "a")

Instances

Instances details
type Eval (First f2 x :: f1 a' b' -> Type) Source # 
Instance details

Defined in Fcf.Class.Bifunctor

type Eval (First f2 x :: f1 a' b' -> Type) = Eval (Bimap f2 (Pure :: b' -> b' -> Type) x)

data Second :: (c -> Exp d) -> f a c -> Exp (f a d) Source #

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

This is generally equivalent to Map.

Example

Expand
>>> :kind! Eval (Second ((+) 1) '("a",3))
Eval (Second ((+) 1) '("a",3)) :: (Symbol, Nat)
= '("a", 4)

Instances

Instances details
type Eval (Second g x :: f a' b' -> Type) Source # 
Instance details

Defined in Fcf.Class.Bifunctor

type Eval (Second g x :: f a' b' -> Type) = Eval (Bimap (Pure :: a' -> a' -> Type) g x)