Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Profunctor.Cartesian
Synopsis
- class Profunctor p => Cartesian (p :: Type -> Type -> Type) where
- prodDay :: forall (r :: Type -> Type -> Type) (p :: Type -> Type -> Type) (q :: Type -> Type -> Type). Cartesian r => (p :-> r) -> (q :-> r) -> Day (,) p q :-> r
- class Profunctor p => Cocartesian (p :: Type -> Type -> Type) where
- 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
- pureDefault :: Cartesian p => b -> p a b
- proUnitDefault :: Applicative (p a) => p a ()
- liftA2Default :: Cartesian p => (a -> b -> c) -> p x a -> p x b -> p x c
- fanoutDefault :: (Profunctor p, Applicative (p a)) => p a b1 -> p a b2 -> p a (b1, b2)
- describeFinite :: forall (n :: Nat) p. (KnownNat n, Cartesian p, Cocartesian p) => p (Finite n) (Finite n)
- describeFiniteBits :: (FiniteBits a, Cartesian p, Cocartesian p) => p a a
Documentation
class Profunctor p => Cartesian (p :: Type -> Type -> Type) where Source #
Minimal complete definition
proUnit, (proProduct | (***) | (&&&))
Methods
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
Cartesian Counting Source # | |
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 # | |
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 # | |
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 (ForgetCocartesian p) Source # | |
Defined in Data.Profunctor.Cartesian.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 (FreeCartesian p) Source # | |
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 (FreeCocartesian p) Source # | |
Defined in Data.Profunctor.Cartesian.Free Methods proUnit :: FreeCocartesian p a () Source # proProduct :: (a -> (a1, a2)) -> ((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 (a, a') (b, b') Source # (&&&) :: FreeCocartesian p a b -> FreeCocartesian p a b' -> FreeCocartesian p a (b, b') Source # proPower :: forall (n :: Nat) a b. KnownNat n => FreeCocartesian p a b -> FreeCocartesian p (Finite n -> a) (Finite n -> b) Source # | |
Cartesian (FreeBicartesian p) Source # | |
Defined in Data.Profunctor.Cartesian.FreeBicartesian 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 # | |
Profunctor p => Cartesian (FreeBicartesianD p) Source # | |
Defined in Data.Profunctor.Cartesian.FreeBicartesian Methods proUnit :: FreeBicartesianD p a () Source # proProduct :: (a -> (a1, a2)) -> ((b1, b2) -> b) -> FreeBicartesianD p a1 b1 -> FreeBicartesianD p a2 b2 -> FreeBicartesianD p a b Source # (***) :: FreeBicartesianD p a b -> FreeBicartesianD p a' b' -> FreeBicartesianD p (a, a') (b, b') Source # (&&&) :: FreeBicartesianD p a b -> FreeBicartesianD p a b' -> FreeBicartesianD p a (b, b') Source # proPower :: forall (n :: Nat) a b. KnownNat n => FreeBicartesianD p a b -> FreeBicartesianD p (Finite n -> a) (Finite n -> b) Source # | |
Cartesian (Encoding a) Source # | |
Defined in Data.Profunctor.UniconEncoding Methods proUnit :: Encoding a a0 () Source # proProduct :: (a0 -> (a1, a2)) -> ((b1, b2) -> b) -> Encoding a a1 b1 -> Encoding a a2 b2 -> Encoding a a0 b Source # (***) :: Encoding a a0 b -> Encoding a a' b' -> Encoding a (a0, a') (b, b') Source # (&&&) :: Encoding a a0 b -> Encoding a a0 b' -> Encoding a a0 (b, b') Source # proPower :: forall (n :: Nat) a0 b. KnownNat n => Encoding a a0 b -> Encoding a (Finite n -> a0) (Finite n -> b) Source # | |
Cartesian p => Cartesian (Coyoneda p) Source # | |
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 # | |
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 # | |
Monoid r => Cartesian (Forget r :: Type -> Type -> Type) Source # | |
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 # | |
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 # | |
Defined in Data.Profunctor.Cartesian Methods 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 # | |
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 # | |
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 # | |
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 # | |
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 #
Methods
Unit of the sum.
The type of proEmpty
can be understood as proEmpty' :: p Void
treated to have more generally-typed Void
p Void b
using rmap
.
absurd
:: Void -> b proEmpty' :: p Void Voidrmap
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
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 #
describeFiniteBits :: (FiniteBits a, Cartesian p, Cocartesian p) => p a a Source #