| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Control.Category.Tensor
Synopsis
- data Iso cat a b = Iso {}
- class (Category cat1, Category cat2, Category cat3) => GBifunctor cat1 cat2 cat3 t | t cat3 -> cat1 cat2 where
- gbimap :: cat1 a b -> cat2 c d -> cat3 (a `t` c) (b `t` d)
- (#) :: GBifunctor cat1 cat2 cat3 t => cat1 a b -> cat2 c d -> cat3 (a `t` c) (b `t` d)
- grmap :: GBifunctor cat1 cat2 cat3 t => cat2 c d -> cat3 (a `t` c) (a `t` d)
- glmap :: GBifunctor cat1 cat2 cat3 t => cat1 a b -> cat3 (a `t` c) (b `t` c)
- class (Category cat, GBifunctor cat cat cat t) => Associative cat t where
- class Associative cat t => Tensor cat t i | t -> i where
- class Associative cat t => Symmetric cat t where
- swap :: cat (a `t` b) (b `t` a)
Iso
GBifunctor
class (Category cat1, Category cat2, Category cat3) => GBifunctor cat1 cat2 cat3 t | t cat3 -> cat1 cat2 where Source #
A Bifunctor t is a Functor whose domain is the product of two
categories. GBifunctor is equivalent to the ordinary
Bifunctor class but we replace the implicit (->) Category with
three distinct higher kinded variables cat1, cat2, and cat3 allowing the user
to pickout a functor from \(cat_1 \times cat_2\) to \(cat_3\).
Laws
gbimapidid≡idgrmapid≡idglmapid≡idgbimap(f.g) (h.i) ≡gbimapf h.gbimapg igrmap(f.g) ≡grmapf.grmapgglmap(f.g) ≡glmapf.glmapg
Instances
| GBifunctor (->) (->) (->) t => GBifunctor Op Op Op t Source # | |
| GBifunctor cat cat cat t => GBifunctor (Iso cat) (Iso cat) (Iso cat) t Source # | |
| GBifunctor (Star Maybe) (Star Maybe) (Star Maybe) These Source # | |
| Bifunctor t => GBifunctor (->) (->) (->) t Source # | |
Defined in Control.Category.Tensor | |
(#) :: GBifunctor cat1 cat2 cat3 t => cat1 a b -> cat2 c d -> cat3 (a `t` c) (b `t` d) infixr 9 Source #
Infix operator for gbimap.
grmap :: GBifunctor cat1 cat2 cat3 t => cat2 c d -> cat3 (a `t` c) (a `t` d) Source #
Covariantally map over the right variable.
glmap :: GBifunctor cat1 cat2 cat3 t => cat1 a b -> cat3 (a `t` c) (b `t` c) Source #
Covariantally map over the left variable.
Associative
class (Category cat, GBifunctor cat cat cat t) => Associative cat t where Source #
A bifunctor \(\_\otimes\_: \mathcal{C} \times \mathcal{C} \to \mathcal{C}\) is
Associative if it is equipped with a
natural isomorphism of the form
\(\alpha_{x,y,z} : (x \otimes (y \otimes z)) \to ((x \otimes y) \otimes z)\), which
we call assoc.
Laws
fwdassoc.bwdassoc≡idbwdassoc.fwdassoc≡id
Methods
assoc :: Iso cat (a `t` (b `t` c)) ((a `t` b) `t` c) Source #
The natural isomorphism between left and
right associated nestings of t.
Examples
>>>:t assoc @(->) @(,)assoc @(->) @(,) :: Iso (->) (a, (b, c)) ((a, b), c)
>>>fwd (assoc @(->) @(,)) (1, ("hello", True))((1,"hello"),True)
Instances
| Associative (->) t => Associative Op t Source # | |
| (Monad m, Associative (->) t, GBifunctor (Star m) (Star m) (Star m) t) => Associative (Star m) t Source # | |
| Associative (->) Either Source # | |
| Associative (->) These Source # | |
| Associative (->) (,) Source # | |
Defined in Control.Category.Tensor | |
Tensor
class Associative cat t => Tensor cat t i | t -> i where Source #
A bifunctor \(\_ \otimes\_ \ : \mathcal{C} \times \mathcal{C} \to \mathcal{C}\)
that maps out of the product category \(\mathcal{C} \times \mathcal{C}\)
is a Tensor if it has:
- a corresponding identity type \(I\)
- Left and right unitor
operations \(\lambda_{x} : 1 \otimes x \to x\) and \(\rho_{x} : x \otimes 1 \to x\), which we call
unitrandunitl.
Laws
fwdunitr(a ⊗ i) ≡ abwdunitra ≡ (a ⊗ i)fwdunitl(i ⊗ a) ≡ abwdunitla ≡ (i ⊗ a)
Methods
unitl :: Iso cat (i `t` a) a Source #
The natural isomorphism between (i `t` a) and a.
Examples
>>>fwd (unitl @_ @(,)) ((), True)True
>>>bwd (unitl @_ @(,)) True((),True)
>>>bwd (unitl @_ @Either) TrueRight True
>>>:t bwd (unitl @_ @Either) Truebwd (unitl @_ @Either) True :: Either Void Bool
unitr :: Iso cat (a `t` i) a Source #
The natural isomorphism between (a `t` i) and a.
Examples
>>>fwd (unitr @_ @(,)) (True, ())True
>>>bwd (unitr @_ @(,)) True(True,())
>>>bwd (unitr @_ @Either) TrueLeft True
>>>:t bwd (unitr @_ @Either) Truebwd (unitr @_ @Either) True :: Either Bool Void
Symmetric
class Associative cat t => Symmetric cat t where Source #
A bifunctor \(\_ \otimes\_ \ : \mathcal{C} \times \mathcal{C} \to \mathcal{C}\)
is Symmetric if it has a product operation \(B_{x,y} : x \otimes y \to y \otimes x\)
such that \(B_{x,y} \circ B_{x,y} \equiv 1_{x \otimes y}\), which we call swap.
Laws
swap.swap≡id
Methods
swap :: cat (a `t` b) (b `t` a) Source #
swap is a symmetry isomorphism for t
Examples
>>>:t swap @(->) @(,)swap @(->) @(,) :: (a, b) -> (b, a)
>>>swap @(->) @(,) (True, "hello")("hello",True)
>>>:t swap @(->) @Either (Left True)swap @(->) @Either (Left True) :: Either b Bool
>>>swap @(->) @Either (Left True)Right True
Instances
| Symmetric (->) t => Symmetric Op t Source # | |
Defined in Control.Category.Tensor | |
| (Monad m, Symmetric (->) t, Associative (Star m) t) => Symmetric (Star m) t Source # | |
Defined in Control.Category.Tensor | |
| Symmetric (->) Either Source # | |
| Symmetric (->) These Source # | |
| Symmetric (->) (,) Source # | |
Defined in Control.Category.Tensor | |