-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Categories -- @package hask @version 0 module Hask.Category -- | Side-conditions moved to Functor to work around GHC bug #9200. -- -- You should produce instances of Category' and consume instances -- of Category. -- -- All of our categories are "locally small", and we curry the -- Hom-functor as a functor to the category of copresheaves rather than -- present it as a bifunctor directly. The benefit of this encoding is -- that a bifunctor is just a functor to a functor category! -- --
--   C :: C^op -> [ C, Set ]
--   
class Category' (p :: i -> i -> *) where type family Ob p :: i -> Constraint unop = getOp op = Op id :: (Category' p, Ob p a) => p a a observe :: Category' p => p a b -> Dict (Ob p a, Ob p b) (.) :: Category' p => p b c -> p a b -> p a c unop :: Category' p => Op p b a -> p a b op :: Category' p => p b a -> Op p a b class (Category' p, Bifunctor p, Dom p ~ Op p, p ~ Op (Dom p), Cod p ~ Nat p (->), Dom2 p ~ p, Cod2 p ~ (->)) => Category'' p -- | The full definition for a (locally-small) category. class (Category'' p, Category'' (Op p), p ~ Op (Op p), Ob p ~ Ob (Op p)) => Category p class (Category' (Dom f), Category' (Cod f)) => Functor (f :: i -> j) where type family Dom f :: i -> i -> * type family Cod f :: j -> j -> * fmap :: Functor f => Dom f a b -> Cod f (f a) (f b) class (Functor f, Dom f ~ p, Cod f ~ q) => FunctorOf p q f ob :: Functor f => Ob (Dom f) a :- Ob (Cod f) (f a) obOf :: (Category (Dom f), Category (Cod f)) => NatId f -> Endo (Dom f) a -> Dict (Ob (Nat (Dom f) (Cod f)) f, Ob (Dom f) a, Ob (Cod f) (f a)) contramap :: Functor f => Opd f b a -> Cod f (f a) (f b) class (Functor p, Cod p ~ Nat (Dom2 p) (Cod2 p), Category' (Dom2 p), Category' (Cod2 p)) => Bifunctor (p :: i -> j -> k) type Cod2 p = NatCod (Cod p) type Dom2 p = NatDom (Cod p) fmap1 :: (Bifunctor p, Ob (Dom p) c) => Dom2 p a b -> Cod2 p (p c a) (p c b) first :: (Functor f, Cod f ~ Nat d e, Ob d c) => Dom f a b -> e (f a c) (f b c) bimap :: Bifunctor p => Dom p a b -> Dom2 p c d -> Cod2 p (p a c) (p b d) -- | E-Enriched profunctors f : C -/-> D are represented by a functor of -- the form: -- -- C^op -> [ D, E ] -- -- The variance here matches Haskell's order, which means that the -- contravariant argument comes first! dimap :: Bifunctor p => Opd p b a -> Dom2 p c d -> Cod2 p (p a c) (p b d) class Vacuous (c :: i -> i -> *) (a :: i) data Constraint :: BOX newtype (:-) (a :: Constraint) (b :: Constraint) :: Constraint -> Constraint -> * Sub :: (a -> Dict b) -> (:-) -- | Capture a dictionary for a given constraint data Dict ($a :: Constraint) :: Constraint -> * Dict :: Dict a -- | Given that a :- b, derive something that needs a context -- b, using the context a (\\) :: a => (b -> r) -> (:-) a b -> r sub :: (a => Proxy a -> Dict b) -> a :- b -- | Reify the relationship between a class and its superclass constraints -- as a class class Class (b :: Constraint) (h :: Constraint) | h -> b cls :: Class b h => (:-) h b -- | Reify the relationship between an instance head and its body as a -- class class (:=>) (b :: Constraint) (h :: Constraint) | h -> b ins :: (:=>) b h => (:-) b h -- | The Yoneda embedding. -- -- Yoneda_C :: C -> [ C^op, Set ] newtype Yoneda (p :: i -> i -> *) (a :: i) (b :: i) Op :: p b a -> Yoneda getOp :: Yoneda -> p b a type Opd f = Op (Dom f) data Nat (p :: i -> i -> *) (q :: j -> j -> *) (f :: i -> j) (g :: i -> j) Nat :: (forall a. Ob p a => q (f a) (g a)) -> Nat p q f g runNat :: Nat p q f g -> forall a. Ob p a => q (f a) (g a) type NatId p = Endo (Nat (Dom p) (Cod p)) p type Endo p a = p a a nat :: (Category p, Category q, FunctorOf p q f, FunctorOf p q g) => (forall a. Ob p a => Endo p a -> q (f a) (g a)) -> Nat p q f g (!) :: Nat p q f g -> p a a -> q (f a) (g a) type Presheaves p = Nat (Op p) (->) type Copresheaves p = Nat p (->) -- | Application operator. This operator is redundant, since ordinary -- application (f x) means the same as (f $ x). -- However, $ has low, right-associative binding precedence, so it -- sometimes allows parentheses to be omitted; for example: -- --
--   f $ g $ h x  =  f (g (h x))
--   
-- -- It is also useful in higher-order situations, such as map -- ($ 0) xs, or zipWith ($) fs xs. ($) :: (a -> b) -> a -> b -- | The Either type represents values with two possibilities: a -- value of type Either a b is either Left -- a or Right b. -- -- The Either type is sometimes used to represent a value which is -- either correct or an error; by convention, the Left constructor -- is used to hold an error value and the Right constructor is -- used to hold a correct value (mnemonic: "right" also means "correct"). data Either a b :: * -> * -> * Left :: a -> Either a b Right :: b -> Either a b newtype Fix (f :: * -> * -> *) (a :: *) In :: f (Fix f a) a -> Fix out :: Fix -> f (Fix f a) a instance FunctorOf (->) (Nat (->) (->)) p => Functor (Fix p) instance Functor Fix instance Functor (Either a) instance Functor Either instance Functor ((,) a) instance Functor (,) instance (Category' p, Category' q) => Category' (Nat p q) instance (Category' p, Category q) => Functor (Nat p q a) instance (Category' p, Category q) => Functor (Nat p q) instance (Category p, Op p ~ Yoneda p) => Category' (Yoneda p) instance (Category p, Op p ~ Yoneda p) => Functor (Yoneda p a) instance (Category p, Op p ~ Yoneda p) => Functor (Yoneda p) instance Category' (->) instance Functor ((->) a) instance Functor (->) instance Category' (:-) instance Functor ((:-) b) instance Functor (:-) instance (Category' c, Ob c ~ Vacuous c) => Functor (Vacuous c) instance Functor Dict instance Vacuous c a instance (Category'' p, Category'' (Op p), p ~ Op (Op p), Ob p ~ Ob (Op p)) => Category p instance (Category' p, Bifunctor p, Dom p ~ Op p, p ~ Op (Dom p), Cod p ~ Nat p (->), Dom2 p ~ p, Cod2 p ~ (->)) => Category'' p instance (Functor p, Cod p ~ Nat (Dom2 p) (Cod2 p), Category' (Dom2 p), Category' (Cod2 p)) => Bifunctor p instance (Category' p, Category' q) => Functor (FunctorOf p q) instance (Functor f, Dom f ~ p, Cod f ~ q) => FunctorOf p q f module Hask.Iso type Iso c d e s t a b = forall p. (Bifunctor p, Opd p ~ c, Dom2 p ~ d, Cod2 p ~ e) => p a b -> p s t data Get (c :: i -> i -> *) (r :: i) (a :: i) (b :: i) _Get :: Iso (->) (->) (->) (Get c r a b) (Get c r' a' b') (c a r) (c a' r') get :: (Category c, Ob c a) => (Get c a a a -> Get c a s s) -> c s a data Beget (c :: i -> i -> *) (r :: i) (a :: i) (b :: i) _Beget :: Iso (->) (->) (->) (Beget c r a b) (Beget c r' a' b') (c r b) (c r' b') beget :: (Category c, Ob c b) => (Beget c b b b -> Beget c b t t) -> c b t (#) :: (Beget (->) b b b -> Beget (->) b t t) -> b -> t yoneda :: (Ob p a, FunctorOf p (->) g, FunctorOf p (->) (p b)) => Iso (->) (->) (->) (Nat p (->) (p a) f) (Nat p (->) (p b) g) (f a) (g b) instance (Category c, Ob c r, Ob c a) => Functor (Beget c r a) instance (Category c, Ob c r) => Functor (Beget c r) instance Category c => Functor (Beget c) instance (Category c, Ob c r, Ob c a) => Functor (Get c r a) instance (Category c, Ob c r) => Functor (Get c r) instance Category c => Functor (Get c) module Hask.Functor.Faithful class Functor f => FullyFaithful f unfmap :: FullyFaithful f => Cod f (f a) (f b) -> Dom f a b instance FullyFaithful (:-) instance FullyFaithful (->) instance FullyFaithful Dict module Hask.Category.Polynomial data Product (p :: i -> i -> *) (q :: j -> j -> *) (a :: (i, j)) (b :: (i, j)) Product :: (p (Fst a) (Fst b)) -> (q (Snd a) (Snd b)) -> Product class (Ob p (Fst a), Ob q (Snd a)) => ProductOb (p :: i -> i -> *) (q :: j -> j -> *) (a :: (i, j)) data Coproduct (c :: i -> i -> *) (d :: j -> j -> *) (a :: Either i j) (b :: Either i j) Inl :: c x y -> Coproduct c d (Left x) (Left y) Inr :: d x y -> Coproduct c d (Right x) (Right y) class CoproductOb (p :: i -> i -> *) (q :: j -> j -> *) (a :: Either i j) side :: CoproductOb p q a => Endo (Coproduct p q) a -> (forall x. (a ~ Left x, Ob p x) => r) -> (forall y. (a ~ Right y, Ob q y) => r) -> r coproductId :: CoproductOb p q a => Endo (Coproduct p q) a data Unit a b Unit :: Unit a b data Empty (a :: Void) (b :: Void) -- | A logically uninhabited data type. data Void :: * -- | Since Void values logically don't exist, this witnesses the -- logical reasoning tool of "ex falso quodlibet". absurd :: Void -> a instance FullyFaithful (Unit a) instance FullyFaithful Unit instance Category' Unit instance Functor (Unit a) instance Functor Unit instance (Category p, Category q) => Category' (Coproduct p q) instance (Category p, Category q) => Functor (Coproduct p q a) instance (Category p, Category q) => Functor (Coproduct p q) instance (Category q, Ob q y) => CoproductOb p q ('Right y) instance (Category p, Ob p x) => CoproductOb p q ('Left x) instance (Category p, Category q) => Category' (Product p q) instance (Category p, Category q, ProductOb p q a) => Functor (Product p q a) instance (Category p, Category q) => Functor (Product p q) instance (Ob p (Fst a), Ob q (Snd a)) => ProductOb p q a module Hask.Prof type Prof c d = Nat (Op c) (Nat d (->)) class (Bifunctor f, Dom f ~ Op p, Dom2 f ~ q, Cod2 f ~ (->)) => ProfunctorOf p q f data Procompose (c :: i -> i -> *) (d :: j -> j -> *) (e :: k -> k -> *) (p :: j -> k -> *) (q :: i -> j -> *) (a :: i) (b :: k) Procompose :: p x b -> q a x -> Procompose c d e p q a b instance (Category c, Category d, Category e, ProfunctorOf d e p, ProfunctorOf c d q, Ob c a) => Functor (Procompose c d e p q a) instance (Category c, Category d, Category e, ProfunctorOf d e p, ProfunctorOf c d q) => Functor (Procompose c d e p q) instance (Category c, Category d, Category e, ProfunctorOf d e p) => Functor (Procompose c d e p) instance (Category c, Category d, Category e) => Functor (Procompose c d e) instance (Bifunctor f, Dom f ~ Op p, Dom2 f ~ q, Cod2 f ~ (->)) => ProfunctorOf p q f module Hask.Tensor class (Bifunctor p, Dom p ~ Dom2 p, Dom p ~ Cod2 p) => Semitensor p associate :: (Semitensor p, Ob (Dom p) a, Ob (Dom p) b, Ob (Dom p) c, Ob (Dom p) a', Ob (Dom p) b', Ob (Dom p) c') => Iso (Dom p) (Dom p) (->) (p (p a b) c) (p (p a' b') c') (p a (p b c)) (p a' (p b' c')) class Semitensor p => Tensor' p lambda :: (Tensor' p, Ob (Dom p) a, Ob (Dom p) a') => Iso (Dom p) (Dom p) (->) (p (I p) a) (p (I p) a') a a' rho :: (Tensor' p, Ob (Dom p) a, Ob (Dom p) a') => Iso (Dom p) (Dom p) (->) (p a (I p)) (p a' (I p)) a a' class (Monoid' p (I p), Tensor' p) => Tensor p semitensorClosed :: (Semitensor t, Category c, Dom t ~ c, Ob c x, Ob c y) => Dict (Ob c (t x y)) class Semitensor p => Semigroup p m mu :: Semigroup p m => Dom p (p m m) m class (Semigroup p m, Tensor' p) => Monoid' p m eta :: Monoid' p m => NatId p -> Dom p (I p) m class (Monoid' p (I p), Comonoid' p (I p), Tensor' p, Monoid' p m) => Monoid p m class Semitensor p => Cosemigroup p w delta :: Cosemigroup p w => Dom p w (p w w) class (Cosemigroup p w, Tensor' p) => Comonoid' p w epsilon :: Comonoid' p w => NatId p -> Dom p w (I p) class (Monoid' p (I p), Comonoid' p (I p), Tensor' p, Comonoid' p w) => Comonoid p w instance Comonoid' Either Void instance Cosemigroup Either Void instance Monoid' Either Void instance Semigroup Either Void instance Semigroup (,) Void instance Tensor' Either instance Semitensor Either instance Comonoid' (,) a instance Cosemigroup (,) a instance Monoid' (,) () instance Semigroup (,) () instance Tensor' (,) instance Semitensor (,) instance Comonoid' (&) a instance Cosemigroup (&) a instance Monoid' (&) () instance Semigroup (&) a instance Tensor' (&) instance Semitensor (&) instance Functor ((&) a) instance Functor (&) instance (p, q) => p & q instance (Monoid' p (I p), Comonoid' p (I p), Tensor' p, Comonoid' p w) => Comonoid p w instance (Monoid' p (I p), Comonoid' p (I p), Tensor' p, Monoid' p m) => Monoid p m instance (Monoid' p (I p), Tensor' p) => Tensor p module Hask.Tensor.Compose data COMPOSE Compose :: COMPOSE type Compose = (Any Compose :: (i -> i -> *) -> (j -> j -> *) -> (k -> k -> *) -> (j -> k) -> (i -> j) -> i -> k) class Category e => Composed (e :: k -> k -> *) _Compose :: (Composed e, FunctorOf d e f, FunctorOf d e f', FunctorOf c d g, FunctorOf c d g') => Iso e e (->) (Compose c d e f g a) (Compose c d e f' g' a') (f (g a)) (f' (g' a')) data ID Id :: ID type Id = (Any Id :: (i -> i -> *) -> i -> i) class Category c => Identified (c :: i -> i -> *) _Id :: Identified c => Iso c c (->) (Id c a) (Id c a') a a' associateCompose :: (Category b, Category c, Composed d, Composed e, FunctorOf d e f, FunctorOf c d g, FunctorOf b c h, FunctorOf d e f', FunctorOf c d g', FunctorOf b c h') => Iso (Nat b e) (Nat b e) (->) (Compose b c e (Compose c d e f g) h) (Compose b c e (Compose c d e f' g') h') (Compose b d e f (Compose b c d g h)) (Compose b d e f' (Compose b c d g' h')) lambdaCompose :: (Identified c, Composed c, Ob (Nat c c) a, Ob (Nat c c) a') => Iso (Nat c c) (Nat c c) (->) (Compose c c c (Id c) a) (Compose c c c (Id c) a') a a' rhoCompose :: (Identified c, Composed c, Ob (Nat c c) a, Ob (Nat c c) a') => Iso (Nat c c) (Nat c c) (->) (Compose c c c a (Id c)) (Compose c c c a' (Id c)) a a' class (Functor m, Dom m ~ Cod m, Monoid (Compose (Dom m) (Dom m) (Dom m)) m, Identified (Dom m), Composed (Dom m)) => Monad m return :: (Monad m, Ob (Dom m) a) => Dom m a (m a) bind :: (Monad m, Ob (Dom m) b) => Dom m a (m b) -> Dom m (m a) (m b) instance (Functor m, Dom m ~ Cod m, Monoid (Compose (Dom m) (Dom m) (Dom m)) m, Identified (Dom m), Composed (Dom m)) => Monad m instance (Identified c, Composed c) => Tensor' (Compose c c c) instance (Identified c, Composed c) => Comonoid' (Compose c c c) (Id c) instance (Identified c, Composed c) => Cosemigroup (Compose c c c) (Id c) instance (Identified c, Composed c) => Monoid' (Compose c c c) (Id c) instance (Identified c, Composed c) => Semigroup (Compose c c c) (Id c) instance Identified c => Functor (Id c) instance Category c => a :=> Id c a instance Category c => Class a (Id c a) instance (Category c, Identified d) => Identified (Nat c d) instance Identified (:-) instance Identified (->) instance (Composed c, c ~ c', c' ~ c'') => Semitensor (Compose c c' c'') instance (Category c, Category d, Composed e, Functor f, Functor g, e ~ Cod f, d ~ Cod g, d ~ Dom f, c ~ Dom g) => Functor (Compose c d e f g) instance (Category c, Category d, Composed e, Functor f, e ~ Cod f, d ~ Dom f) => Functor (Compose c d e f) instance (Category c, Category d, Composed e) => Functor (Compose c d e) instance (Category c, Category d, Category e) => f (g a) :=> Compose c d e f g a instance (Category c, Category d, Category e) => Class (f (g a)) (Compose c d e f g a) instance (Category c, Composed d) => Composed (Nat c d) instance Composed (:-) instance Composed (->) module Hask.Tensor.Day class FunctorOf c (->) f => CopresheafOf c f data Day (t :: i -> i -> i) (f :: i -> *) (g :: i -> *) (a :: i) Day :: c (t x y) a -> f x -> g y -> Day t f g a instance (Semitensor t, Dom t ~ c, Category c) => Semitensor (Day t) instance (Dom t ~ c, Category c) => Functor (Day t) instance (Dom t ~ c, CopresheafOf c f) => Functor (Day t f) instance (Dom t ~ c, CopresheafOf c f, CopresheafOf c g) => Functor (Day t f g) instance FunctorOf c (->) f => CopresheafOf c f module Hask.Adjunction class (Functor f, Functor g, Dom f ~ Cod g, Cod g ~ Dom f) => (-|) (f :: j -> i) (g :: i -> j) | f -> g, g -> f adj :: (-|) f g => Iso (->) (->) (->) (Cod f (f a) b) (Cod f (f a') b') (Cod g a (g b)) (Cod g a' (g b')) swap :: (a, b) -> (b, a) class (Bifunctor p, Bifunctor q) => Curried (p :: k -> i -> j) (q :: i -> j -> k) | p -> q, q -> p curried :: Curried p q => Iso (->) (->) (->) (Dom2 p (p a b) c) (Dom2 p (p a' b') c') (Dom2 q a (q b c)) (Dom2 q a' (q b' c')) instance Curried (,) (->) instance (,) e -| (->) e