cartesian-profunctors
Safe HaskellNone
LanguageHaskell2010

Data.Profunctor.Cartesian

Synopsis

Documentation

class Profunctor p => Cartesian (p :: Type -> Type -> Type) where Source #

Minimal complete definition

proUnit, (proProduct | (***) | (&&&))

Methods

proUnit :: p a () Source #

Unit of the product.

The type of proUnit can be understood as proUnit' :: p () () treated to have more generally-typed p a () using lmap.

const () :: a -> ()
proUnit' :: p () ()
lmap (const ()) proUnit' :: p a ()

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> p a1 b1 -> p a2 b2 -> p a b Source #

(***) :: p a b -> p a' b' -> p (a, a') (b, b') Source #

Product of two profunctors

(&&&) :: p a b -> p a b' -> p a (b, b') Source #

Alternative way to define the product (pronounced "fan-out")

proPower :: forall (n :: Nat) a b. KnownNat n => p a b -> p (Finite n -> a) (Finite n -> b) Source #

Function from finite types can be constructed as iterated product.

There is a default implementaion, but it can be more efficient implementation.

Instances

Instances details
Cartesian Counting Source # 
Instance details

Defined in Data.Profunctor.Counting

Methods

proUnit :: Counting a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Counting a1 b1 -> Counting a2 b2 -> Counting a b Source #

(***) :: Counting a b -> Counting a' b' -> Counting (a, a') (b, b') Source #

(&&&) :: Counting a b -> Counting a b' -> Counting a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Counting a b -> Counting (Finite n -> a) (Finite n -> b) Source #

Cartesian Exhaust Source # 
Instance details

Defined in Data.Profunctor.Exhaust

Methods

proUnit :: Exhaust a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Exhaust a1 b1 -> Exhaust a2 b2 -> Exhaust a b Source #

(***) :: Exhaust a b -> Exhaust a' b' -> Exhaust (a, a') (b, b') Source #

(&&&) :: Exhaust a b -> Exhaust a b' -> Exhaust a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Exhaust a b -> Exhaust (Finite n -> a) (Finite n -> b) Source #

Cartesian FinFn Source # 
Instance details

Defined in Data.Profunctor.FinFn

Methods

proUnit :: FinFn a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> FinFn a1 b1 -> FinFn a2 b2 -> FinFn a b Source #

(***) :: FinFn a b -> FinFn a' b' -> FinFn (a, a') (b, b') Source #

(&&&) :: FinFn a b -> FinFn a b' -> FinFn a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => FinFn a b -> FinFn (Finite n -> a) (Finite n -> b) Source #

Cartesian p => Cartesian (FreeBicartesian p) Source # 
Instance details

Defined in Data.Profunctor.Bicartesian.Free

Methods

proUnit :: FreeBicartesian p a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> FreeBicartesian p a1 b1 -> FreeBicartesian p a2 b2 -> FreeBicartesian p a b Source #

(***) :: FreeBicartesian p a b -> FreeBicartesian p a' b' -> FreeBicartesian p (a, a') (b, b') Source #

(&&&) :: FreeBicartesian p a b -> FreeBicartesian p a b' -> FreeBicartesian p a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => FreeBicartesian p a b -> FreeBicartesian p (Finite n -> a) (Finite n -> b) Source #

Cartesian (FreeCartesian p) Source # 
Instance details

Defined in Data.Profunctor.Cartesian.Free

Methods

proUnit :: FreeCartesian p a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> FreeCartesian p a1 b1 -> FreeCartesian p a2 b2 -> FreeCartesian p a b Source #

(***) :: FreeCartesian p a b -> FreeCartesian p a' b' -> FreeCartesian p (a, a') (b, b') Source #

(&&&) :: FreeCartesian p a b -> FreeCartesian p a b' -> FreeCartesian p a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => FreeCartesian p a b -> FreeCartesian p (Finite n -> a) (Finite n -> b) Source #

Cartesian p => Cartesian (ForgetCocartesian p) Source # 
Instance details

Defined in Data.Profunctor.Cocartesian.Free

Methods

proUnit :: ForgetCocartesian p a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> ForgetCocartesian p a1 b1 -> ForgetCocartesian p a2 b2 -> ForgetCocartesian p a b Source #

(***) :: ForgetCocartesian p a b -> ForgetCocartesian p a' b' -> ForgetCocartesian p (a, a') (b, b') Source #

(&&&) :: ForgetCocartesian p a b -> ForgetCocartesian p a b' -> ForgetCocartesian p a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => ForgetCocartesian p a b -> ForgetCocartesian p (Finite n -> a) (Finite n -> b) Source #

Cartesian p => Cartesian (Coyoneda p) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proUnit :: Coyoneda p a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Coyoneda p a1 b1 -> Coyoneda p a2 b2 -> Coyoneda p a b Source #

(***) :: Coyoneda p a b -> Coyoneda p a' b' -> Coyoneda p (a, a') (b, b') Source #

(&&&) :: Coyoneda p a b -> Coyoneda p a b' -> Coyoneda p a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Coyoneda p a b -> Coyoneda p (Finite n -> a) (Finite n -> b) Source #

Cartesian p => Cartesian (Yoneda p) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proUnit :: Yoneda p a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Yoneda p a1 b1 -> Yoneda p a2 b2 -> Yoneda p a b Source #

(***) :: Yoneda p a b -> Yoneda p a' b' -> Yoneda p (a, a') (b, b') Source #

(&&&) :: Yoneda p a b -> Yoneda p a b' -> Yoneda p a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Yoneda p a b -> Yoneda p (Finite n -> a) (Finite n -> b) Source #

Cartesian (Encoder a b) Source # 
Instance details

Defined in Data.Finitary.PolyRep

Methods

proUnit :: Encoder a b a0 () Source #

proProduct :: (a0 -> (a1, a2)) -> ((b1, b2) -> b0) -> Encoder a b a1 b1 -> Encoder a b a2 b2 -> Encoder a b a0 b0 Source #

(***) :: Encoder a b a0 b0 -> Encoder a b a' b' -> Encoder a b (a0, a') (b0, b') Source #

(&&&) :: Encoder a b a0 b0 -> Encoder a b a0 b' -> Encoder a b a0 (b0, b') Source #

proPower :: forall (n :: Nat) a0 b0. KnownNat n => Encoder a b a0 b0 -> Encoder a b (Finite n -> a0) (Finite n -> b0) Source #

Cartesian (Encoder a b) Source # 
Instance details

Defined in Data.Finitary.TreeRep

Methods

proUnit :: Encoder a b a0 () Source #

proProduct :: (a0 -> (a1, a2)) -> ((b1, b2) -> b0) -> Encoder a b a1 b1 -> Encoder a b a2 b2 -> Encoder a b a0 b0 Source #

(***) :: Encoder a b a0 b0 -> Encoder a b a' b' -> Encoder a b (a0, a') (b0, b') Source #

(&&&) :: Encoder a b a0 b0 -> Encoder a b a0 b' -> Encoder a b a0 (b0, b') Source #

proPower :: forall (n :: Nat) a0 b0. KnownNat n => Encoder a b a0 b0 -> Encoder a b (Finite n -> a0) (Finite n -> b0) Source #

Monoid r => Cartesian (Forget r :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proUnit :: Forget r a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Forget r a1 b1 -> Forget r a2 b2 -> Forget r a b Source #

(***) :: Forget r a b -> Forget r a' b' -> Forget r (a, a') (b, b') Source #

(&&&) :: Forget r a b -> Forget r a b' -> Forget r a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Forget r a b -> Forget r (Finite n -> a) (Finite n -> b) Source #

Applicative f => Cartesian (Star f) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proUnit :: Star f a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Star f a1 b1 -> Star f a2 b2 -> Star f a b Source #

(***) :: Star f a b -> Star f a' b' -> Star f (a, a') (b, b') Source #

(&&&) :: Star f a b -> Star f a b' -> Star f a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Star f a b -> Star f (Finite n -> a) (Finite n -> b) Source #

Cartesian (->) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proUnit :: a -> () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> (a1 -> b1) -> (a2 -> b2) -> a -> b Source #

(***) :: (a -> b) -> (a' -> b') -> (a, a') -> (b, b') Source #

(&&&) :: (a -> b) -> (a -> b') -> a -> (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => (a -> b) -> (Finite n -> a) -> (Finite n -> b) Source #

Divisible f => Cartesian (Clown f :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proUnit :: Clown f a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Clown f a1 b1 -> Clown f a2 b2 -> Clown f a b Source #

(***) :: Clown f a b -> Clown f a' b' -> Clown f (a, a') (b, b') Source #

(&&&) :: Clown f a b -> Clown f a b' -> Clown f a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Clown f a b -> Clown f (Finite n -> a) (Finite n -> b) Source #

Applicative f => Cartesian (Joker f :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proUnit :: Joker f a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Joker f a1 b1 -> Joker f a2 b2 -> Joker f a b Source #

(***) :: Joker f a b -> Joker f a' b' -> Joker f (a, a') (b, b') Source #

(&&&) :: Joker f a b -> Joker f a b' -> Joker f a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Joker f a b -> Joker f (Finite n -> a) (Finite n -> b) Source #

(Cartesian p, Cartesian q) => Cartesian (Product p q) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proUnit :: Product p q a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Product p q a1 b1 -> Product p q a2 b2 -> Product p q a b Source #

(***) :: Product p q a b -> Product p q a' b' -> Product p q (a, a') (b, b') Source #

(&&&) :: Product p q a b -> Product p q a b' -> Product p q a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Product p q a b -> Product p q (Finite n -> a) (Finite n -> b) Source #

(Cartesian p, Cartesian q) => Cartesian (Procompose p q) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proUnit :: Procompose p q a () Source #

proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> Procompose p q a1 b1 -> Procompose p q a2 b2 -> Procompose p q a b Source #

(***) :: Procompose p q a b -> Procompose p q a' b' -> Procompose p q (a, a') (b, b') Source #

(&&&) :: Procompose p q a b -> Procompose p q a b' -> Procompose p q a (b, b') Source #

proPower :: forall (n :: Nat) a b. KnownNat n => Procompose p q a b -> Procompose p q (Finite n -> a) (Finite n -> b) Source #

prodDay :: forall (r :: Type -> Type -> Type) (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Cartesian r => (p :-> r) -> (q :-> r) -> Day (,) p q :-> r Source #

class Profunctor p => Cocartesian (p :: Type -> Type -> Type) where Source #

Minimal complete definition

proEmpty, (proSum | (+++) | (|||))

Methods

proEmpty :: p Void b Source #

Unit of the sum.

The type of proEmpty can be understood as proEmpty' :: p Void Void treated to have more generally-typed p Void b using rmap.

absurd    :: Void -> b
proEmpty' :: p Void Void
rmap absurd proEmpty' :: p Void b

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> p a1 b1 -> p a2 b2 -> p a b Source #

(+++) :: p a b -> p a' b' -> p (Either a a') (Either b b') Source #

Sum of two profunctors

(|||) :: p a b -> p a' b -> p (Either a a') b Source #

Alternative way to define the sum (pronounced "fan-in")

proTimes :: forall (n :: Nat) a b. KnownNat n => p a b -> p (Finite n, a) (Finite n, b) Source #

Pairing with finite types can be constructed as iterated sum.

There is a default implementaion, but it can be more efficient implementation.

Instances

Instances details
Cocartesian Counting Source # 
Instance details

Defined in Data.Profunctor.Counting

Methods

proEmpty :: Counting Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Counting a1 b1 -> Counting a2 b2 -> Counting a b Source #

(+++) :: Counting a b -> Counting a' b' -> Counting (Either a a') (Either b b') Source #

(|||) :: Counting a b -> Counting a' b -> Counting (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Counting a b -> Counting (Finite n, a) (Finite n, b) Source #

Cocartesian Exhaust Source # 
Instance details

Defined in Data.Profunctor.Exhaust

Methods

proEmpty :: Exhaust Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Exhaust a1 b1 -> Exhaust a2 b2 -> Exhaust a b Source #

(+++) :: Exhaust a b -> Exhaust a' b' -> Exhaust (Either a a') (Either b b') Source #

(|||) :: Exhaust a b -> Exhaust a' b -> Exhaust (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Exhaust a b -> Exhaust (Finite n, a) (Finite n, b) Source #

Cocartesian FinFn Source # 
Instance details

Defined in Data.Profunctor.FinFn

Methods

proEmpty :: FinFn Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> FinFn a1 b1 -> FinFn a2 b2 -> FinFn a b Source #

(+++) :: FinFn a b -> FinFn a' b' -> FinFn (Either a a') (Either b b') Source #

(|||) :: FinFn a b -> FinFn a' b -> FinFn (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => FinFn a b -> FinFn (Finite n, a) (Finite n, b) Source #

Profunctor p => Cocartesian (FreeBicartesian p) Source # 
Instance details

Defined in Data.Profunctor.Bicartesian.Free

Methods

proEmpty :: FreeBicartesian p Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> FreeBicartesian p a1 b1 -> FreeBicartesian p a2 b2 -> FreeBicartesian p a b Source #

(+++) :: FreeBicartesian p a b -> FreeBicartesian p a' b' -> FreeBicartesian p (Either a a') (Either b b') Source #

(|||) :: FreeBicartesian p a b -> FreeBicartesian p a' b -> FreeBicartesian p (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => FreeBicartesian p a b -> FreeBicartesian p (Finite n, a) (Finite n, b) Source #

Cocartesian p => Cocartesian (ForgetCartesian p) Source # 
Instance details

Defined in Data.Profunctor.Cartesian.Free

Methods

proEmpty :: ForgetCartesian p Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> ForgetCartesian p a1 b1 -> ForgetCartesian p a2 b2 -> ForgetCartesian p a b Source #

(+++) :: ForgetCartesian p a b -> ForgetCartesian p a' b' -> ForgetCartesian p (Either a a') (Either b b') Source #

(|||) :: ForgetCartesian p a b -> ForgetCartesian p a' b -> ForgetCartesian p (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => ForgetCartesian p a b -> ForgetCartesian p (Finite n, a) (Finite n, b) Source #

Profunctor p => Cocartesian (FreeCocartesian p) Source # 
Instance details

Defined in Data.Profunctor.Cocartesian.Free

Methods

proEmpty :: FreeCocartesian p Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> FreeCocartesian p a1 b1 -> FreeCocartesian p a2 b2 -> FreeCocartesian p a b Source #

(+++) :: FreeCocartesian p a b -> FreeCocartesian p a' b' -> FreeCocartesian p (Either a a') (Either b b') Source #

(|||) :: FreeCocartesian p a b -> FreeCocartesian p a' b -> FreeCocartesian p (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => FreeCocartesian p a b -> FreeCocartesian p (Finite n, a) (Finite n, b) Source #

Cocartesian p => Cocartesian (Coyoneda p) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proEmpty :: Coyoneda p Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Coyoneda p a1 b1 -> Coyoneda p a2 b2 -> Coyoneda p a b Source #

(+++) :: Coyoneda p a b -> Coyoneda p a' b' -> Coyoneda p (Either a a') (Either b b') Source #

(|||) :: Coyoneda p a b -> Coyoneda p a' b -> Coyoneda p (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Coyoneda p a b -> Coyoneda p (Finite n, a) (Finite n, b) Source #

Cocartesian p => Cocartesian (Yoneda p) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proEmpty :: Yoneda p Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Yoneda p a1 b1 -> Yoneda p a2 b2 -> Yoneda p a b Source #

(+++) :: Yoneda p a b -> Yoneda p a' b' -> Yoneda p (Either a a') (Either b b') Source #

(|||) :: Yoneda p a b -> Yoneda p a' b -> Yoneda p (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Yoneda p a b -> Yoneda p (Finite n, a) (Finite n, b) Source #

Cocartesian (Encoder a b) Source # 
Instance details

Defined in Data.Finitary.PolyRep

Methods

proEmpty :: Encoder a b Void b0 Source #

proSum :: (a0 -> Either a1 a2) -> (Either b1 b2 -> b0) -> Encoder a b a1 b1 -> Encoder a b a2 b2 -> Encoder a b a0 b0 Source #

(+++) :: Encoder a b a0 b0 -> Encoder a b a' b' -> Encoder a b (Either a0 a') (Either b0 b') Source #

(|||) :: Encoder a b a0 b0 -> Encoder a b a' b0 -> Encoder a b (Either a0 a') b0 Source #

proTimes :: forall (n :: Nat) a0 b0. KnownNat n => Encoder a b a0 b0 -> Encoder a b (Finite n, a0) (Finite n, b0) Source #

Cocartesian (Encoder a b) Source # 
Instance details

Defined in Data.Finitary.TreeRep

Methods

proEmpty :: Encoder a b Void b0 Source #

proSum :: (a0 -> Either a1 a2) -> (Either b1 b2 -> b0) -> Encoder a b a1 b1 -> Encoder a b a2 b2 -> Encoder a b a0 b0 Source #

(+++) :: Encoder a b a0 b0 -> Encoder a b a' b' -> Encoder a b (Either a0 a') (Either b0 b') Source #

(|||) :: Encoder a b a0 b0 -> Encoder a b a' b0 -> Encoder a b (Either a0 a') b0 Source #

proTimes :: forall (n :: Nat) a0 b0. KnownNat n => Encoder a b a0 b0 -> Encoder a b (Finite n, a0) (Finite n, b0) Source #

Cocartesian (Forget r :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proEmpty :: Forget r Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Forget r a1 b1 -> Forget r a2 b2 -> Forget r a b Source #

(+++) :: Forget r a b -> Forget r a' b' -> Forget r (Either a a') (Either b b') Source #

(|||) :: Forget r a b -> Forget r a' b -> Forget r (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Forget r a b -> Forget r (Finite n, a) (Finite n, b) Source #

Functor f => Cocartesian (Star f) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proEmpty :: Star f Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Star f a1 b1 -> Star f a2 b2 -> Star f a b Source #

(+++) :: Star f a b -> Star f a' b' -> Star f (Either a a') (Either b b') Source #

(|||) :: Star f a b -> Star f a' b -> Star f (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Star f a b -> Star f (Finite n, a) (Finite n, b) Source #

Cocartesian (->) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proEmpty :: Void -> b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> (a1 -> b1) -> (a2 -> b2) -> a -> b Source #

(+++) :: (a -> b) -> (a' -> b') -> Either a a' -> Either b b' Source #

(|||) :: (a -> b) -> (a' -> b) -> Either a a' -> b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => (a -> b) -> (Finite n, a) -> (Finite n, b) Source #

Decidable f => Cocartesian (Clown f :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proEmpty :: Clown f Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Clown f a1 b1 -> Clown f a2 b2 -> Clown f a b Source #

(+++) :: Clown f a b -> Clown f a' b' -> Clown f (Either a a') (Either b b') Source #

(|||) :: Clown f a b -> Clown f a' b -> Clown f (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Clown f a b -> Clown f (Finite n, a) (Finite n, b) Source #

Alternative f => Cocartesian (Joker f :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proEmpty :: Joker f Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Joker f a1 b1 -> Joker f a2 b2 -> Joker f a b Source #

(+++) :: Joker f a b -> Joker f a' b' -> Joker f (Either a a') (Either b b') Source #

(|||) :: Joker f a b -> Joker f a' b -> Joker f (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Joker f a b -> Joker f (Finite n, a) (Finite n, b) Source #

(Cocartesian p, Cocartesian q) => Cocartesian (Product p q) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proEmpty :: Product p q Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Product p q a1 b1 -> Product p q a2 b2 -> Product p q a b Source #

(+++) :: Product p q a b -> Product p q a' b' -> Product p q (Either a a') (Either b b') Source #

(|||) :: Product p q a b -> Product p q a' b -> Product p q (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Product p q a b -> Product p q (Finite n, a) (Finite n, b) Source #

(Cocartesian p, Cocartesian q) => Cocartesian (Procompose p q) Source # 
Instance details

Defined in Data.Profunctor.Cartesian

Methods

proEmpty :: Procompose p q Void b Source #

proSum :: (a -> Either a1 a2) -> (Either b1 b2 -> b) -> Procompose p q a1 b1 -> Procompose p q a2 b2 -> Procompose p q a b Source #

(+++) :: Procompose p q a b -> Procompose p q a' b' -> Procompose p q (Either a a') (Either b b') Source #

(|||) :: Procompose p q a b -> Procompose p q a' b -> Procompose p q (Either a a') b Source #

proTimes :: forall (n :: Nat) a b. KnownNat n => Procompose p q a b -> Procompose p q (Finite n, a) (Finite n, b) Source #

sumDay :: forall (r :: Type -> Type -> Type) (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Cocartesian r => (p :-> r) -> (q :-> r) -> Day Either p q :-> r Source #

Cartesian p iff forall x. Applicative (p x)

pureDefault :: Cartesian p => b -> p a b Source #

proUnitDefault :: Applicative (p a) => p a () Source #

liftA2Default :: Cartesian p => (a -> b -> c) -> p x a -> p x b -> p x c Source #

fanoutDefault :: (Profunctor p, Applicative (p a)) => p a b1 -> p a b2 -> p a (b1, b2) Source #

Utilities

describeFinite :: forall (n :: Nat) p. (KnownNat n, Cartesian p, Cocartesian p) => p (Finite n) (Finite n) Source #

Laws

Cartesian laws

Instances of Cartesian must satisfy the following equations.

Left unit of ***
dimap ununitL unitL (proUnit *** p) === p
Right unit of ***
dimap ununitR unitR (p *** proUnit) === p
Associativity of ***
dimap assoc unassoc ((p *** q) *** r) === p *** (q *** r)

Some instance of Cartesian optionally satisfy the following equation.

Commutativity of ***
dimap swap swap (p *** q) === q *** p

In this library, an instance of Cartesian is called commutative Cartesian if it satisfy the above commutativity law.

Instances with and without commutativity

TODO fill here: most instance is not commutative, Counting or Forget r for commutative monoid is (positive)

Cocartesian laws

Instances of Cocartesian must satisfy the following equations.

Left unit of +++
dimap unemptyL emptyL (proEmpty +++ p) === p
Right unit of +++
dimap unemptyR emptyR (p +++ proEmpty) === p
Associativity of +++
dimap assoc unassoc ((p +++ q) +++ r) === p +++ (q +++ r)

Some instance of Cocartesian optionally satisfy the following equation.

Commutativity of +++
dimap swap swap (p +++ q) === q +++ p

In this library, an instance of Cocartesian is called commutative Cocartesian if it satisfy the above commutativity law.

Instances with and without commutativity

TODO fill here: Star f, Clown Equivalence (positive) and Clown Comparison, Alternative f => Joker f (negative)

Optional laws for interaction of Cartesian and Cocartesian

If a Profunctor p is an instance of both Cartesian and Cocartesian, there are few named properties they optionally satisfy.

Left zero
dimap absurd (absurd . fst) (proEmpty *** p) === proEmpty
Left distribution
dimap undistL distL ((p +++ q) *** r) === (p *** r) +++ (q *** r)
Right zero
dimap absurd (absurd . snd) (p *** proEmpty) === proEmpty
Right distribution
dimap undistR distR (r *** (p +++ q)) === (r *** p) +++ (r *** q)

In this library, an instance of both Cartesian and Cocartesian is called

  • near-Bicartesian if it additionally satisfy Left zero and Left distribution
  • Bicartesian if it is near-Bicartesian, is commutative Cocartesian, and satisfy all four of Right zero and Right distribution. In other words, satisfy all of above four laws and commutativity of +++.

Instances with/without optional properties

TODO fill here

Note:

In usual mathematical abstract algebra context, it is common practice to name Right distributivity to mean Left zero and Left distibution combined, and same switching for Left distributivity.

The naming convention of this library came from Haskell convention of describing distributive properties of Alternative and MonadPlus.

https://wiki.haskell.org/index.php?title=Typeclassopedia#Laws_6

Type isomorphisms

Re-exports

class Bifunctor p => Assoc (p :: Type -> Type -> Type) where #

"Semigroup-y" Bifunctors.

assoc . unassoc = id
unassoc . assoc = id
assoc . bimap (bimap f g) h = bimap f (bimap g h) . assoc

This library doesn't provide Monoidal class, with left and right unitors. Are they useful in practice?

Methods

assoc :: p (p a b) c -> p a (p b c) #

unassoc :: p a (p b c) -> p (p a b) c #

Instances

Instances details
Assoc Either # 
Instance details

Defined in Data.Bifunctor.Assoc

Methods

assoc :: Either (Either a b) c -> Either a (Either b c) #

unassoc :: Either a (Either b c) -> Either (Either a b) c #

Assoc (,) # 
Instance details

Defined in Data.Bifunctor.Assoc

Methods

assoc :: ((a, b), c) -> (a, (b, c)) #

unassoc :: (a, (b, c)) -> ((a, b), c) #

Assoc (Const :: Type -> Type -> Type) # 
Instance details

Defined in Data.Bifunctor.Assoc

Methods

assoc :: Const (Const a b) c -> Const a (Const b c) #

unassoc :: Const a (Const b c) -> Const (Const a b) c #

Assoc p => Assoc (Flip p) #

Since: bifunctors-5.6.1

Instance details

Defined in Data.Bifunctor.Flip

Methods

assoc :: Flip p (Flip p a b) c -> Flip p a (Flip p b c) #

unassoc :: Flip p a (Flip p b c) -> Flip p (Flip p a b) c #

class Swap (p :: Type -> Type -> Type) where #

Symmetric Bifunctors.

swap . swap = id

If p is a Bifunctor the following property is assumed to hold:

swap . bimap f g = bimap g f . swap

Swap isn't a subclass of Bifunctor, as for example

>>> newtype Bipredicate a b = Bipredicate (a -> b -> Bool)

is not a Bifunctor but has Swap instance

>>> instance Swap Bipredicate where swap (Bipredicate p) = Bipredicate (flip p)

Methods

swap :: p a b -> p b a #

Instances

Instances details
Swap Either # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: Either a b -> Either b a #

Swap (,) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (a, b) -> (b, a) #

Swap ((,,) x) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, a, b) -> (x, b, a) #

Swap ((,,,) x y) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, y, a, b) -> (x, y, b, a) #

Swap p => Swap (Flip p) #

Since: bifunctors-5.6.1

Instance details

Defined in Data.Bifunctor.Flip

Methods

swap :: Flip p a b -> Flip p b a #

Swap ((,,,,) x y z) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, y, z, a, b) -> (x, y, z, b, a) #

(Swap p, Swap q) => Swap (Product p q) #

Since: bifunctors-5.6.1

Instance details

Defined in Data.Bifunctor.Product

Methods

swap :: Product p q a b -> Product p q b a #

(Swap p, Swap q) => Swap (Sum p q) #

Since: bifunctors-5.6.1

Instance details

Defined in Data.Bifunctor.Sum

Methods

swap :: Sum p q a b -> Sum p q b a #

Swap ((,,,,,) x y z w) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, y, z, w, a, b) -> (x, y, z, w, b, a) #

(Functor f, Swap p) => Swap (Tannen f p) #

Since: bifunctors-5.6.1

Instance details

Defined in Data.Bifunctor.Tannen

Methods

swap :: Tannen f p a b -> Tannen f p b a #

Swap ((,,,,,,) x y z w v) # 
Instance details

Defined in Data.Bifunctor.Swap

Methods

swap :: (x, y, z, w, v, a, b) -> (x, y, z, w, v, b, a) #

(f ~ g, Functor f, Swap p) => Swap (Biff p f g) #

Since: bifunctors-5.6.1

Instance details

Defined in Data.Bifunctor.Biff

Methods

swap :: Biff p f g a b -> Biff p f g b a #

Unit laws

unitL :: ((), a) -> a Source #

ununitL :: a -> ((), a) Source #

unitR :: (a, ()) -> a Source #

ununitR :: a -> (a, ()) Source #

Distributivity

distL :: (Either a b, c) -> Either (a, c) (b, c) Source #

undistL :: Either (a, c) (b, c) -> (Either a b, c) Source #

distR :: (c, Either a b) -> Either (c, a) (c, b) Source #

undistR :: Either (c, a) (c, b) -> (c, Either a b) Source #