categories 0.54.0 → 0.54.1
raw patch · 4 files changed
+71/−69 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Control.Category.Cartesian: instance (Comonoidal (~>) (Sum (~>)), PreCoCartesian (~>)) => CoCartesian (~>)
- Control.Category.Cartesian: instance (Monoidal (~>) (Product (~>)), PreCartesian (~>)) => Cartesian (~>)
+ Control.Category.Cartesian: instance (Comonoidal k (Sum k), PreCoCartesian k) => CoCartesian k
+ Control.Category.Cartesian: instance (Monoidal k (Product k), PreCartesian k) => Cartesian k
- Control.Category.Cartesian: (&&&) :: (PreCartesian ~>) => (a ~> b) -> (a ~> c) -> a ~> Product ~> b c
+ Control.Category.Cartesian: (&&&) :: (PreCartesian k) => (a k b) -> (a k c) -> a k Product k b c
- Control.Category.Cartesian: (|||) :: (PreCoCartesian ~>) => (a ~> c) -> (b ~> c) -> Sum ~> a b ~> c
+ Control.Category.Cartesian: (|||) :: (PreCoCartesian k) => (a k c) -> (b k c) -> Sum k a b k c
- Control.Category.Cartesian: associateProduct :: (PreCartesian ~>) => Product ~> (Product ~> a b) c ~> Product ~> a (Product ~> b c)
+ Control.Category.Cartesian: associateProduct :: (PreCartesian k) => Product k (Product k a b) c k Product k a (Product k b c)
- Control.Category.Cartesian: associateSum :: (PreCoCartesian ~>) => Sum ~> (Sum ~> a b) c ~> Sum ~> a (Sum ~> b c)
+ Control.Category.Cartesian: associateSum :: (PreCoCartesian k) => Sum k (Sum k a b) c k Sum k a (Sum k b c)
- Control.Category.Cartesian: bimapProduct :: (PreCartesian ~>, <*> ~ (Product ~>)) => (a ~> c) -> (b ~> d) -> (a <*> b) ~> (c <*> d)
+ Control.Category.Cartesian: bimapProduct :: (PreCartesian k, <*> ~ (Product k)) => (a k c) -> (b k d) -> (a <*> b) k (c <*> d)
- Control.Category.Cartesian: bimapSum :: (PreCoCartesian ~>, (Sum ~>) ~ +) => (a ~> c) -> (b ~> d) -> (a + b) ~> (c + d)
+ Control.Category.Cartesian: bimapSum :: (PreCoCartesian k, (Sum k) ~ +) => (a k c) -> (b k d) -> (a + b) k (c + d)
- Control.Category.Cartesian: braidProduct :: (PreCartesian ~>) => Product ~> a b ~> Product ~> b a
+ Control.Category.Cartesian: braidProduct :: (PreCartesian k) => Product k a b k Product k b a
- Control.Category.Cartesian: braidSum :: (PreCoCartesian ~>, + ~ (Sum ~>)) => (a + b) ~> (b + a)
+ Control.Category.Cartesian: braidSum :: (PreCoCartesian k, + ~ (Sum k)) => (a + b) k (b + a)
- Control.Category.Cartesian: class (Monoidal ~> (Product ~>), PreCartesian ~>) => Cartesian ~>
+ Control.Category.Cartesian: class (Monoidal k (Product k), PreCartesian k) => Cartesian k
- Control.Category.Cartesian: class (Comonoidal ~> (Sum ~>), PreCoCartesian ~>) => CoCartesian ~>
+ Control.Category.Cartesian: class (Comonoidal k (Sum k), PreCoCartesian k) => CoCartesian k
- Control.Category.Cartesian: class (Associative ~> (Product ~>), Disassociative ~> (Product ~>), Symmetric ~> (Product ~>), Braided ~> (Product ~>)) => PreCartesian ~> where { type family Product ~> :: * -> * -> *; { f &&& g = bimap f g . diag diag = id &&& id } }
+ Control.Category.Cartesian: class (Associative k (Product k), Disassociative k (Product k), Symmetric k (Product k), Braided k (Product k)) => PreCartesian k where { type family Product k :: * -> * -> *; { f &&& g = bimap f g . diag diag = id &&& id } }
- Control.Category.Cartesian: class (Associative ~> (Sum ~>), Disassociative ~> (Sum ~>), Symmetric ~> (Product ~>), Braided ~> (Sum ~>)) => PreCoCartesian ~> where { type family Sum ~> :: * -> * -> *; { f ||| g = codiag . bimap f g codiag = id ||| id } }
+ Control.Category.Cartesian: class (Associative k (Sum k), Disassociative k (Sum k), Symmetric k (Product k), Braided k (Sum k)) => PreCoCartesian k where { type family Sum k :: * -> * -> *; { f ||| g = codiag . bimap f g codiag = id ||| id } }
- Control.Category.Cartesian: codiag :: (PreCoCartesian ~>) => Sum ~> a a ~> a
+ Control.Category.Cartesian: codiag :: (PreCoCartesian k) => Sum k a a k a
- Control.Category.Cartesian: diag :: (PreCartesian ~>) => a ~> Product ~> a a
+ Control.Category.Cartesian: diag :: (PreCartesian k) => a k Product k a a
- Control.Category.Cartesian: disassociateProduct :: (PreCartesian ~>) => Product ~> a (Product ~> b c) ~> Product ~> (Product ~> a b) c
+ Control.Category.Cartesian: disassociateProduct :: (PreCartesian k) => Product k a (Product k b c) k Product k (Product k a b) c
- Control.Category.Cartesian: disassociateSum :: (PreCoCartesian ~>) => Sum ~> a (Sum ~> b c) ~> Sum ~> (Sum ~> a b) c
+ Control.Category.Cartesian: disassociateSum :: (PreCoCartesian k) => Sum k a (Sum k b c) k Sum k (Sum k a b) c
- Control.Category.Cartesian: fst :: (PreCartesian ~>) => Product ~> a b ~> a
+ Control.Category.Cartesian: fst :: (PreCartesian k) => Product k a b k a
- Control.Category.Cartesian: inl :: (PreCoCartesian ~>) => a ~> Sum ~> a b
+ Control.Category.Cartesian: inl :: (PreCoCartesian k) => a k Sum k a b
- Control.Category.Cartesian: inr :: (PreCoCartesian ~>) => b ~> Sum ~> a b
+ Control.Category.Cartesian: inr :: (PreCoCartesian k) => b k Sum k a b
- Control.Category.Cartesian: snd :: (PreCartesian ~>) => Product ~> a b ~> b
+ Control.Category.Cartesian: snd :: (PreCartesian k) => Product k a b k b
- Control.Category.Discrete: cast :: (Category ~>) => Discrete a b -> (a ~> b)
+ Control.Category.Discrete: cast :: (Category k) => Discrete a b -> k a b
- Control.Category.Distributive: class (PreCartesian ~>, PreCoCartesian ~>) => Distributive ~>
+ Control.Category.Distributive: class (PreCartesian k, PreCoCartesian k) => Distributive k
- Control.Category.Distributive: distribute :: (Distributive ~>) => Product ~> a (Sum ~> b c) ~> Sum ~> (Product ~> a b) (Product ~> a c)
+ Control.Category.Distributive: distribute :: (Distributive k) => Product k a (Sum k b c) k Sum k (Product k a b) (Product k a c)
- Control.Category.Distributive: factor :: (PreCartesian ~>, PreCoCartesian ~>) => Sum ~> (Product ~> a b) (Product ~> a c) ~> Product ~> a (Sum ~> b c)
+ Control.Category.Distributive: factor :: (PreCartesian k, PreCoCartesian k) => Sum k (Product k a b) (Product k a c) k Product k a (Sum k b c)
Files
- Control/Category/Cartesian.hs +50/−50
- Control/Category/Discrete.hs +1/−1
- Control/Category/Distributive.hs +19/−17
- categories.cabal +1/−1
Control/Category/Cartesian.hs view
@@ -46,16 +46,16 @@ > fst, snd, diag > fst, snd, (&&&) -}-class ( Associative (~>) (Product (~>))- , Disassociative (~>) (Product (~>))- , Symmetric (~>) (Product (~>))- , Braided (~>) (Product (~>))- ) => PreCartesian (~>) where- type Product (~>) :: * -> * -> *- fst :: Product (~>) a b ~> a- snd :: Product (~>) a b ~> b- diag :: a ~> Product (~>) a a- (&&&) :: (a ~> b) -> (a ~> c) -> a ~> Product (~>) b c+class ( Associative k (Product k)+ , Disassociative k (Product k)+ , Symmetric k (Product k)+ , Braided k (Product k)+ ) => PreCartesian k where+ type Product k :: * -> * -> *+ fst :: Product k a b `k` a+ snd :: Product k a b `k` b+ diag :: a `k` Product k a a+ (&&&) :: (a `k` b) -> (a `k` c) -> a `k` Product k b c diag = id &&& id f &&& g = bimap f g . diag@@ -76,45 +76,45 @@ (f &&& g) a = (f a, g a) -- alias-class ( Monoidal (~>) (Product (~>))- , PreCartesian (~>)- ) => Cartesian (~>)-instance ( Monoidal (~>) (Product (~>))- , PreCartesian (~>)- ) => Cartesian (~>)+class ( Monoidal k (Product k)+ , PreCartesian k+ ) => Cartesian k+instance ( Monoidal k (Product k)+ , PreCartesian k+ ) => Cartesian k -- | free construction of 'Bifunctor' for the product 'Bifunctor' @Product k@ if @(&&&)@ is known-bimapProduct :: (PreCartesian (~>), (<*>) ~ Product (~>)) => (a ~> c) -> (b ~> d) -> (a <*> b) ~> (c <*> d)+bimapProduct :: (PreCartesian k, (<*>) ~ Product k) => (a `k` c) -> (b `k` d) -> (a <*> b) `k` (c <*> d) bimapProduct f g = (f . fst) &&& (g . snd) -- | free construction of 'Braided' for the product 'Bifunctor' @Product k@--- braidProduct :: (PreCartesian (~>), Product (~>) ~ (<*>)) => a <*> b ~> b <*> a-braidProduct :: (PreCartesian (~>)) => Product (~>) a b ~> Product (~>) b a+-- braidProduct :: (PreCartesian k, Product k ~ (<*>)) => a <*> b ~> b <*> a+braidProduct :: (PreCartesian k) => Product k a b `k` Product k b a braidProduct = snd &&& fst -- | free construction of 'Associative' for the product 'Bifunctor' @Product k@--- associateProduct :: (PreCartesian (~>), (<*>) ~ Product (~>)) => (a <*> b) <*> c ~> (a <*> (b <*> c))-associateProduct :: (PreCartesian (~>)) => Product (~>) (Product (~>) a b) c ~> Product (~>) a (Product (~>) b c)+-- associateProduct :: (PreCartesian k, (<*>) ~ Product k) => (a <*> b) <*> c ~> (a <*> (b <*> c))+associateProduct :: (PreCartesian k) => Product k (Product k a b) c `k` Product k a (Product k b c) associateProduct = (fst . fst) &&& first snd -- | free construction of 'Disassociative' for the product 'Bifunctor' @Product k@--- disassociateProduct:: (PreCartesian (~>), (<*>) ~ Product (~>)) => a <*> (b <*> c) ~> (a <*> b) <*> c-disassociateProduct:: (PreCartesian (~>)) => Product (~>) a (Product (~>) b c) ~> Product (~>) (Product (~>) a b) c+-- disassociateProduct:: (PreCartesian k, (<*>) ~ Product k) => a <*> (b <*> c) ~> (a <*> b) <*> c+disassociateProduct:: (PreCartesian k) => Product k a (Product k b c) `k` Product k (Product k a b) c disassociateProduct= braid . second braid . associateProduct . first braid . braid -- * Co-PreCartesian categories --- a category that has finite coproducts, wea(~>)ened the same way as PreCartesian above was wea(~>)ened-class ( Associative (~>) (Sum (~>))- , Disassociative (~>) (Sum (~>))- , Symmetric (~>) (Product (~>))- , Braided (~>) (Sum (~>))- ) => PreCoCartesian (~>) where- type Sum (~>) :: * -> * -> *- inl :: a ~> Sum (~>) a b- inr :: b ~> Sum (~>) a b- codiag :: Sum (~>) a a ~> a- (|||) :: (a ~> c) -> (b ~> c) -> Sum (~>) a b ~> c+-- a category that has finite coproducts, weakened the same way as PreCartesian above was weakened+class ( Associative k (Sum k)+ , Disassociative k (Sum k)+ , Symmetric k (Product k)+ , Braided k (Sum k)+ ) => PreCoCartesian k where+ type Sum k :: * -> * -> *+ inl :: a `k` Sum k a b+ inr :: b `k` Sum k a b+ codiag :: Sum k a a `k` a+ (|||) :: (a `k` c) -> (b `k` c) -> Sum k a b `k` c codiag = id ||| id f ||| g = codiag . bimap f g@@ -135,29 +135,29 @@ (f ||| _) (Left a) = f a (_ ||| g) (Right a) = g a --- | free construction of 'Bifunctor' for the coproduct 'Bifunctor' @Sum (~>)@ if @(|||)@ is known-bimapSum :: (PreCoCartesian (~>), Sum (~>) ~ (+)) => (a ~> c) -> (b ~> d) -> (a + b) ~> (c + d)+-- | free construction of 'Bifunctor' for the coproduct 'Bifunctor' @Sum k@ if @(|||)@ is known+bimapSum :: (PreCoCartesian k, Sum k ~ (+)) => (a `k` c) -> (b `k` d) -> (a + b) `k` (c + d) bimapSum f g = (inl . f) ||| (inr . g) --- | free construction of 'Braided' for the coproduct 'Bifunctor' @Sum (~>)@-braidSum :: (PreCoCartesian (~>), (+) ~ Sum (~>)) => (a + b) ~> (b + a)+-- | free construction of 'Braided' for the coproduct 'Bifunctor' @Sum k@+braidSum :: (PreCoCartesian k, (+) ~ Sum k) => (a + b) `k` (b + a) braidSum = inr ||| inl --- | free construction of 'Associative' for the coproduct 'Bifunctor' @Sum (~>)@--- associateSum :: (PreCoCartesian (~>), (+) ~ Sum (~>)) => ((a + b) + c) ~> (a + (b + c))-associateSum :: (PreCoCartesian (~>)) => Sum (~>) (Sum (~>) a b) c ~> Sum (~>) a (Sum (~>) b c)+-- | free construction of 'Associative' for the coproduct 'Bifunctor' @Sum k@+-- associateSum :: (PreCoCartesian k, (+) ~ Sum k) => ((a + b) + c) ~> (a + (b + c))+associateSum :: (PreCoCartesian k) => Sum k (Sum k a b) c `k` Sum k a (Sum k b c) associateSum = braid . first braid . disassociateSum . second braid . braid --- | free construction of 'Disassociative' for the coproduct 'Bifunctor' @Sum (~>)@--- disassociateSum :: (PreCoCartesian (~>), (+) ~ Sum (~>)) => (a + (b + c)) ~> ((a + b) + c)-disassociateSum :: (PreCoCartesian (~>)) => Sum (~>) a (Sum (~>) b c) ~> Sum (~>) (Sum (~>) a b) c+-- | free construction of 'Disassociative' for the coproduct 'Bifunctor' @Sum k@+-- disassociateSum :: (PreCoCartesian k, (+) ~ Sum k) => (a + (b + c)) ~> ((a + b) + c)+disassociateSum :: (PreCoCartesian k) => Sum k a (Sum k b c) `k` Sum k (Sum k a b) c disassociateSum = (inl . inl) ||| first inr class - ( Comonoidal (~>) (Sum (~>))- , PreCoCartesian (~>)- ) => CoCartesian (~>)+ ( Comonoidal k (Sum k)+ , PreCoCartesian k+ ) => CoCartesian k instance - ( Comonoidal (~>) (Sum (~>))- , PreCoCartesian (~>)- ) => CoCartesian (~>)+ ( Comonoidal k (Sum k)+ , PreCoCartesian k+ ) => CoCartesian k
Control/Category/Discrete.hs view
@@ -34,7 +34,7 @@ liftDiscrete Refl = Refl -- | Lower the proof that a ~ b to an arbitrary category.-cast :: Category (~>) => Discrete a b -> (a ~> b)+cast :: Category k => Discrete a b -> k a b cast Refl = id -- |
Control/Category/Distributive.hs view
@@ -22,28 +22,30 @@ import Control.Category import Control.Category.Cartesian --- | the canonical factoring morphism +-- | The canonical factoring morphism. -- --- > factor :: ( PreCartesian (~>)--- > , (*) ~ Product (~>)--- > , PreCoCartesian (~>)--- > , (+) ~ Sum (~>) --- > ) => ((a * b) + (a * c)) ~> (a * (b + c))+-- > factor :: ( PreCartesian k+-- > , (*) ~ Product k+-- > , PreCoCartesian k+-- > , (+) ~ Sum k +-- > ) => ((a * b) + (a * c)) `k` (a * (b + c)) -factor :: ( PreCartesian (~>)- , PreCoCartesian (~>)- ) => Sum (~>) (Product (~>) a b) (Product (~>) a c) ~> Product (~>) a (Sum (~>) b c)+factor :: ( PreCartesian k+ , PreCoCartesian k+ ) => Sum k (Product k a b) (Product k a c) `k` Product k a (Sum k b c) factor = second inl ||| second inr -- | A category in which 'factor' is an isomorphism--- > class ( PreCartesian (~>) --- > , (*) ~ Product (~>)--- > , PreCoCartesian (~>)--- > , (+) ~ Sum (~>) --- > ) => Distributive (~>) where-class (PreCartesian (~>), PreCoCartesian (~>)) => Distributive (~>) where- distribute :: Product (~>) a (Sum (~>) b c) ~> Sum (~>) (Product (~>) a b) (Product (~>) a c)+--+-- > class ( PreCartesian k +-- > , (*) ~ Product k+-- > , PreCoCartesian k+-- > , (+) ~ Sum k +-- > ) => Distributive k where +class (PreCartesian k, PreCoCartesian k) => Distributive k where+ distribute :: Product k a (Sum k b c) `k` Sum k (Product k a b) (Product k a c)+ instance Distributive (->) where distribute (a, Left b) = Left (a,b) distribute (a, Right c) = Right (a,c)@@ -51,4 +53,4 @@ {-# RULES "factor . distribute" factor . distribute = id "distribute . factor" distribute . factor = id- #-}+ #-}
categories.cabal view
@@ -1,6 +1,6 @@ name: categories category: Control-version: 0.54.0+version: 0.54.1 license: BSD3 cabal-version: >= 1.2 license-file: LICENSE