constrained-categories-0.4.2.0: Constrained clones of the category-theory type classes, using ConstraintKinds.
Copyright(c) 2013-2016 Justus Sagemüller
LicenseGPL v3 (see COPYING)
Maintainer(@) jsag $ hvl.no
Safe HaskellTrustworthy
LanguageHaskell2010

Control.Category.Constrained

Description

The most basic category theory tools are included partly in this module, partly in Control.Arrow.Constrained.

Synopsis

The category class

class Category (k :: κ -> κ -> Type) where Source #

In mathematics, a category is defined as a class of objects, plus a class of morphisms between those objects. In Haskell, one traditionally works in the category (->) (called Hask), in which any Haskell type is an object. But of course there are lots of useful categories where the objects are much more specific, e.g. vector spaces with linear maps as morphisms. The obvious way to express this in Haskell is as type class constraints, and the ConstraintKinds extension allows quantifying over such object classes.

Like in Control.Category, "the category k" means actually k is the morphism type constructor. From a mathematician's point of view this may seem a bit strange way to define the category, but it just turns out to be quite convenient for practical purposes.

Associated Types

type Object k (o :: κ) :: Constraint Source #

type Object k o = ()

Methods

id :: Object k a => k a a Source #

(.) :: (Object k a, Object k b, Object k c) => k b c -> k a b -> k a c infixr 9 Source #

Instances

Instances details
Category Op Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type Object Op o Source #

Methods

id :: forall (a :: κ). Object Op a => Op a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object Op a, Object Op b, Object Op c) => Op b c -> Op a b -> Op a c Source #

Cartesian k => Category (ReCartesian k :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type Object (ReCartesian k) o Source #

Methods

id :: forall (a :: κ). Object (ReCartesian k) a => ReCartesian k a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (ReCartesian k) a, Object (ReCartesian k) b, Object (ReCartesian k) c) => ReCartesian k b c -> ReCartesian k a b -> ReCartesian k a c Source #

Category k => Category (ReCategory k :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type Object (ReCategory k) o Source #

Methods

id :: forall (a :: κ). Object (ReCategory k) a => ReCategory k a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (ReCategory k) a, Object (ReCategory k) b, Object (ReCategory k) c) => ReCategory k b c -> ReCategory k a b -> ReCategory k a c Source #

Morphism k => Category (ReMorphism k :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type Object (ReMorphism k) o Source #

Methods

id :: forall (a :: κ). Object (ReMorphism k) a => ReMorphism k a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (ReMorphism k) a, Object (ReMorphism k) b, Object (ReMorphism k) c) => ReMorphism k b c -> ReMorphism k a b -> ReMorphism k a c Source #

PreArrow k => Category (RePreArrow k :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type Object (RePreArrow k) o Source #

Methods

id :: forall (a :: κ). Object (RePreArrow k) a => RePreArrow k a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (RePreArrow k) a, Object (RePreArrow k) b, Object (RePreArrow k) c) => RePreArrow k b c -> RePreArrow k a b -> RePreArrow k a c Source #

WellPointed k => Category (ReWellPointed k :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type Object (ReWellPointed k) o Source #

Methods

id :: forall (a :: κ). Object (ReWellPointed k) a => ReWellPointed k a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (ReWellPointed k) a, Object (ReWellPointed k) b, Object (ReWellPointed k) c) => ReWellPointed k b c -> ReWellPointed k a b -> ReWellPointed k a c Source #

Category (Coercion :: κ -> κ -> Type) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type Object Coercion o Source #

Methods

id :: forall (a :: κ0). Object Coercion a => Coercion a a Source #

(.) :: forall (a :: κ0) (b :: κ0) (c :: κ0). (Object Coercion a, Object Coercion b, Object Coercion c) => Coercion b c -> Coercion a b -> Coercion a c Source #

Category (Discrete :: κ -> κ -> Type) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type Object Discrete o Source #

Methods

id :: forall (a :: κ0). Object Discrete a => Discrete a a Source #

(.) :: forall (a :: κ0) (b :: κ0) (c :: κ0). (Object Discrete a, Object Discrete b, Object Discrete c) => Discrete b c -> Discrete a b -> Discrete a c Source #

(Category k, Category l) => Category (k × l :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type Object (k × l) o Source #

Methods

id :: forall (a :: κ). Object (k × l) a => (k × l) a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (k × l) a, Object (k × l) b, Object (k × l) c) => (k × l) b c -> (k × l) a b -> (k × l) a c Source #

Category k => Category (isObj k :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type Object (isObj k) o Source #

Methods

id :: forall (a :: κ). Object (isObj k) a => (isObj k) a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (isObj k) a, Object (isObj k) b, Object (isObj k) c) => (isObj k) b c -> (isObj k) a b -> (isObj k) a c Source #

Monad m k => Category (Kleisli m k :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Monad.Constrained

Associated Types

type Object (Kleisli m k) o Source #

Methods

id :: forall (a :: κ). Object (Kleisli m k) a => Kleisli m k a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (Kleisli m k) a, Object (Kleisli m k) b, Object (Kleisli m k) c) => Kleisli m k b c -> Kleisli m k a b -> Kleisli m k a c Source #

Category (->) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type Object (->) o Source #

Methods

id :: forall (a :: κ). Object (->) a => a -> a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (->) a, Object (->) b, Object (->) c) => (b -> c) -> (a -> b) -> a -> c Source #

Monoidal categories

class (Category k, Monoid (UnitObject k), Object k (UnitObject k)) => Cartesian k where Source #

Quite a few categories (monoidal categories) will permit "products" of objects as objects again – in the Haskell sense those are tuples – allowing for "dyadic morphisms" (x,y) ~> r.

Together with a unique UnitObject, this makes for a monoidal structure, with a few natural isomorphisms. Ordinary tuples may not always be powerful enough to express the product objects; we avoid making a dedicated associated type for the sake of simplicity, but allow for an extra constraint to be imposed on objects prior to consideration of pair-building.

The name Cartesian is disputable: in category theory that would rather Imply cartesian closed category (which we represent with Curry). Monoidal would make sense, but we reserve that to Functors.

Associated Types

type PairObjects k a b :: Constraint Source #

Extra properties two types a, b need to fulfill so (a,b) can be an object of the category. This need not take care for a and b themselves being objects, we do that seperately: every function that actually deals with (a,b) objects should require the stronger ObjectPair k a b.

If any two object types of your category make up a pair object, then just leave PairObjects at the default (empty constraint).

type PairObjects k a b = ()

type UnitObject k :: * Source #

Defaults to (), and should normally be left at that.

type UnitObject k = ()

Methods

swap :: (ObjectPair k a b, ObjectPair k b a) => k (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject k, ObjectPair k a unit) => k a (a, unit) Source #

detachUnit :: (unit ~ UnitObject k, ObjectPair k a unit) => k (a, unit) a Source #

regroup :: (ObjectPair k a b, ObjectPair k b c, ObjectPair k a (b, c), ObjectPair k (a, b) c) => k (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair k a b, ObjectPair k b c, ObjectPair k a (b, c), ObjectPair k (a, b) c) => k ((a, b), c) (a, (b, c)) Source #

Instances

Instances details
Cartesian Op Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type PairObjects Op a b Source #

type UnitObject Op Source #

Methods

swap :: (ObjectPair Op a b, ObjectPair Op b a) => Op (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject Op, ObjectPair Op a unit) => Op a (a, unit) Source #

detachUnit :: (unit ~ UnitObject Op, ObjectPair Op a unit) => Op (a, unit) a Source #

regroup :: (ObjectPair Op a b, ObjectPair Op b c, ObjectPair Op a (b, c), ObjectPair Op (a, b) c) => Op (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair Op a b, ObjectPair Op b c, ObjectPair Op a (b, c), ObjectPair Op (a, b) c) => Op ((a, b), c) (a, (b, c)) Source #

Cartesian k => Cartesian (ReCartesian k) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type PairObjects (ReCartesian k) a b Source #

type UnitObject (ReCartesian k) Source #

Methods

swap :: (ObjectPair (ReCartesian k) a b, ObjectPair (ReCartesian k) b a) => ReCartesian k (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject (ReCartesian k), ObjectPair (ReCartesian k) a unit) => ReCartesian k a (a, unit) Source #

detachUnit :: (unit ~ UnitObject (ReCartesian k), ObjectPair (ReCartesian k) a unit) => ReCartesian k (a, unit) a Source #

regroup :: (ObjectPair (ReCartesian k) a b, ObjectPair (ReCartesian k) b c, ObjectPair (ReCartesian k) a (b, c), ObjectPair (ReCartesian k) (a, b) c) => ReCartesian k (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair (ReCartesian k) a b, ObjectPair (ReCartesian k) b c, ObjectPair (ReCartesian k) a (b, c), ObjectPair (ReCartesian k) (a, b) c) => ReCartesian k ((a, b), c) (a, (b, c)) Source #

Morphism k => Cartesian (ReMorphism k) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type PairObjects (ReMorphism k) a b Source #

type UnitObject (ReMorphism k) Source #

Methods

swap :: (ObjectPair (ReMorphism k) a b, ObjectPair (ReMorphism k) b a) => ReMorphism k (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject (ReMorphism k), ObjectPair (ReMorphism k) a unit) => ReMorphism k a (a, unit) Source #

detachUnit :: (unit ~ UnitObject (ReMorphism k), ObjectPair (ReMorphism k) a unit) => ReMorphism k (a, unit) a Source #

regroup :: (ObjectPair (ReMorphism k) a b, ObjectPair (ReMorphism k) b c, ObjectPair (ReMorphism k) a (b, c), ObjectPair (ReMorphism k) (a, b) c) => ReMorphism k (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair (ReMorphism k) a b, ObjectPair (ReMorphism k) b c, ObjectPair (ReMorphism k) a (b, c), ObjectPair (ReMorphism k) (a, b) c) => ReMorphism k ((a, b), c) (a, (b, c)) Source #

PreArrow k => Cartesian (RePreArrow k) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type PairObjects (RePreArrow k) a b Source #

type UnitObject (RePreArrow k) Source #

Methods

swap :: (ObjectPair (RePreArrow k) a b, ObjectPair (RePreArrow k) b a) => RePreArrow k (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject (RePreArrow k), ObjectPair (RePreArrow k) a unit) => RePreArrow k a (a, unit) Source #

detachUnit :: (unit ~ UnitObject (RePreArrow k), ObjectPair (RePreArrow k) a unit) => RePreArrow k (a, unit) a Source #

regroup :: (ObjectPair (RePreArrow k) a b, ObjectPair (RePreArrow k) b c, ObjectPair (RePreArrow k) a (b, c), ObjectPair (RePreArrow k) (a, b) c) => RePreArrow k (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair (RePreArrow k) a b, ObjectPair (RePreArrow k) b c, ObjectPair (RePreArrow k) a (b, c), ObjectPair (RePreArrow k) (a, b) c) => RePreArrow k ((a, b), c) (a, (b, c)) Source #

WellPointed k => Cartesian (ReWellPointed k) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type PairObjects (ReWellPointed k) a b Source #

type UnitObject (ReWellPointed k) Source #

Methods

swap :: (ObjectPair (ReWellPointed k) a b, ObjectPair (ReWellPointed k) b a) => ReWellPointed k (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject (ReWellPointed k), ObjectPair (ReWellPointed k) a unit) => ReWellPointed k a (a, unit) Source #

detachUnit :: (unit ~ UnitObject (ReWellPointed k), ObjectPair (ReWellPointed k) a unit) => ReWellPointed k (a, unit) a Source #

regroup :: (ObjectPair (ReWellPointed k) a b, ObjectPair (ReWellPointed k) b c, ObjectPair (ReWellPointed k) a (b, c), ObjectPair (ReWellPointed k) (a, b) c) => ReWellPointed k (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair (ReWellPointed k) a b, ObjectPair (ReWellPointed k) b c, ObjectPair (ReWellPointed k) a (b, c), ObjectPair (ReWellPointed k) (a, b) c) => ReWellPointed k ((a, b), c) (a, (b, c)) Source #

(Cartesian k, Cartesian l) => Cartesian (k × l) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type PairObjects (k × l) a b Source #

type UnitObject (k × l) Source #

Methods

swap :: (ObjectPair (k × l) a b, ObjectPair (k × l) b a) => (k × l) (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject (k × l), ObjectPair (k × l) a unit) => (k × l) a (a, unit) Source #

detachUnit :: (unit ~ UnitObject (k × l), ObjectPair (k × l) a unit) => (k × l) (a, unit) a Source #

regroup :: (ObjectPair (k × l) a b, ObjectPair (k × l) b c, ObjectPair (k × l) a (b, c), ObjectPair (k × l) (a, b) c) => (k × l) (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair (k × l) a b, ObjectPair (k × l) b c, ObjectPair (k × l) a (b, c), ObjectPair (k × l) (a, b) c) => (k × l) ((a, b), c) (a, (b, c)) Source #

(Cartesian f, o (UnitObject f)) => Cartesian (o f) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type PairObjects (o f) a b Source #

type UnitObject (o f) Source #

Methods

swap :: (ObjectPair (o f) a b, ObjectPair (o f) b a) => (o f) (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject (o f), ObjectPair (o f) a unit) => (o f) a (a, unit) Source #

detachUnit :: (unit ~ UnitObject (o f), ObjectPair (o f) a unit) => (o f) (a, unit) a Source #

regroup :: (ObjectPair (o f) a b, ObjectPair (o f) b c, ObjectPair (o f) a (b, c), ObjectPair (o f) (a, b) c) => (o f) (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair (o f) a b, ObjectPair (o f) b c, ObjectPair (o f) a (b, c), ObjectPair (o f) (a, b) c) => (o f) ((a, b), c) (a, (b, c)) Source #

(Monad m a, Cartesian a) => Cartesian (Kleisli m a) Source # 
Instance details

Defined in Control.Monad.Constrained

Associated Types

type PairObjects (Kleisli m a) a b Source #

type UnitObject (Kleisli m a) Source #

Methods

swap :: (ObjectPair (Kleisli m a) a0 b, ObjectPair (Kleisli m a) b a0) => Kleisli m a (a0, b) (b, a0) Source #

attachUnit :: (unit ~ UnitObject (Kleisli m a), ObjectPair (Kleisli m a) a0 unit) => Kleisli m a a0 (a0, unit) Source #

detachUnit :: (unit ~ UnitObject (Kleisli m a), ObjectPair (Kleisli m a) a0 unit) => Kleisli m a (a0, unit) a0 Source #

regroup :: (ObjectPair (Kleisli m a) a0 b, ObjectPair (Kleisli m a) b c, ObjectPair (Kleisli m a) a0 (b, c), ObjectPair (Kleisli m a) (a0, b) c) => Kleisli m a (a0, (b, c)) ((a0, b), c) Source #

regroup' :: (ObjectPair (Kleisli m a) a0 b, ObjectPair (Kleisli m a) b c, ObjectPair (Kleisli m a) a0 (b, c), ObjectPair (Kleisli m a) (a0, b) c) => Kleisli m a ((a0, b), c) (a0, (b, c)) Source #

Cartesian (->) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type PairObjects (->) a b Source #

type UnitObject (->) Source #

Methods

swap :: (ObjectPair (->) a b, ObjectPair (->) b a) => (a, b) -> (b, a) Source #

attachUnit :: (unit ~ UnitObject (->), ObjectPair (->) a unit) => a -> (a, unit) Source #

detachUnit :: (unit ~ UnitObject (->), ObjectPair (->) a unit) => (a, unit) -> a Source #

regroup :: (ObjectPair (->) a b, ObjectPair (->) b c, ObjectPair (->) a (b, c), ObjectPair (->) (a, b) c) => (a, (b, c)) -> ((a, b), c) Source #

regroup' :: (ObjectPair (->) a b, ObjectPair (->) b c, ObjectPair (->) a (b, c), ObjectPair (->) (a, b) c) => ((a, b), c) -> (a, (b, c)) Source #

type ObjectPair k a b = (Category k, Object k a, Object k b, PairObjects k a b, Object k (a, b)) Source #

Use this constraint to ensure that a, b and (a,b) are all "fully valid" objects of your category (meaning, you can use them with the Cartesian combinators).

class Cartesian k => Curry k where Source #

Minimal complete definition

uncurry, curry

Associated Types

type MorphObjects k b c :: Constraint Source #

type MorphObjects k b c = ()

Methods

uncurry :: (ObjectPair k a b, ObjectMorphism k b c) => k a (k b c) -> k (a, b) c Source #

curry :: (ObjectPair k a b, ObjectMorphism k b c) => k (a, b) c -> k a (k b c) Source #

apply :: (ObjectMorphism k a b, ObjectPair k (k a b) a) => k (k a b, a) b Source #

Instances

Instances details
(Curry f, o (UnitObject f)) => Curry (o f) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type MorphObjects (o f) b c Source #

Methods

uncurry :: (ObjectPair (o f) a b, ObjectMorphism (o f) b c) => (o f) a ((o f) b c) -> (o f) (a, b) c Source #

curry :: (ObjectPair (o f) a b, ObjectMorphism (o f) b c) => (o f) (a, b) c -> (o f) a ((o f) b c) Source #

apply :: (ObjectMorphism (o f) a b, ObjectPair (o f) ((o f) a b) a) => (o f) ((o f) a b, a) b Source #

(Monad m a, Arrow a (->), Function a) => Curry (Kleisli m a) Source # 
Instance details

Defined in Control.Monad.Constrained

Associated Types

type MorphObjects (Kleisli m a) b c Source #

Methods

uncurry :: (ObjectPair (Kleisli m a) a0 b, ObjectMorphism (Kleisli m a) b c) => Kleisli m a a0 (Kleisli m a b c) -> Kleisli m a (a0, b) c Source #

curry :: (ObjectPair (Kleisli m a) a0 b, ObjectMorphism (Kleisli m a) b c) => Kleisli m a (a0, b) c -> Kleisli m a a0 (Kleisli m a b c) Source #

apply :: (ObjectMorphism (Kleisli m a) a0 b, ObjectPair (Kleisli m a) (Kleisli m a a0 b) a0) => Kleisli m a (Kleisli m a a0 b, a0) b Source #

Curry (->) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type MorphObjects (->) b c Source #

Methods

uncurry :: (ObjectPair (->) a b, ObjectMorphism (->) b c) => (a -> (b -> c)) -> (a, b) -> c Source #

curry :: (ObjectPair (->) a b, ObjectMorphism (->) b c) => ((a, b) -> c) -> a -> (b -> c) Source #

apply :: (ObjectMorphism (->) a b, ObjectPair (->) (a -> b) a) => (a -> b, a) -> b Source #

type ObjectMorphism k b c = (Object k b, Object k c, MorphObjects k b c, Object k (k b c)) Source #

Analogous to ObjectPair: express that k b c be an exponential object representing the morphism.

Monoidal with coproducts

class (Category k, Object k (ZeroObject k)) => CoCartesian k where Source #

Monoidal categories need not be based on a cartesian product. The relevant alternative is coproducts.

The dual notion to Cartesian replaces such products (pairs) with sums (Either), and unit () with void types.

Basically, the only thing that doesn't mirror Cartesian here is that we don't require CoMonoid (ZeroObject k). Comonoids do in principle make sense, but not from a Haskell viewpoint (every type is trivially a comonoid).

Haskell of course uses sum types, variants, most often without Either appearing. But variants are generally isomorphic to sums; the most important (sums of unit) are methods here.

Associated Types

type SumObjects k a b :: Constraint Source #

type SumObjects k a b = ()

type ZeroObject k :: * Source #

Defaults to Void.

type ZeroObject k = Void

Methods

coSwap :: (ObjectSum k a b, ObjectSum k b a) => k (a + b) (b + a) Source #

attachZero :: (Object k a, zero ~ ZeroObject k, ObjectSum k a zero) => k a (a + zero) Source #

detachZero :: (Object k a, zero ~ ZeroObject k, ObjectSum k a zero) => k (a + zero) a Source #

coRegroup :: (Object k a, Object k c, ObjectSum k a b, ObjectSum k b c, ObjectSum k a (b + c), ObjectSum k (a + b) c) => k (a + (b + c)) ((a + b) + c) Source #

coRegroup' :: (Object k a, Object k c, ObjectSum k a b, ObjectSum k b c, ObjectSum k a (b + c), ObjectSum k (a + b) c) => k ((a + b) + c) (a + (b + c)) Source #

maybeAsSum :: (ObjectSum k u a, u ~ UnitObject k, Object k (Maybe a)) => k (Maybe a) (u + a) Source #

maybeFromSum :: (ObjectSum k u a, u ~ UnitObject k, Object k (Maybe a)) => k (u + a) (Maybe a) Source #

boolAsSum :: (ObjectSum k u u, u ~ UnitObject k, Object k Bool) => k Bool (u + u) Source #

boolFromSum :: (ObjectSum k u u, u ~ UnitObject k, Object k Bool) => k (u + u) Bool Source #

Instances

Instances details
CoCartesian Op Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type SumObjects Op a b Source #

type ZeroObject Op Source #

Methods

coSwap :: (ObjectSum Op a b, ObjectSum Op b a) => Op (a + b) (b + a) Source #

attachZero :: (Object Op a, zero ~ ZeroObject Op, ObjectSum Op a zero) => Op a (a + zero) Source #

detachZero :: (Object Op a, zero ~ ZeroObject Op, ObjectSum Op a zero) => Op (a + zero) a Source #

coRegroup :: (Object Op a, Object Op c, ObjectSum Op a b, ObjectSum Op b c, ObjectSum Op a (b + c), ObjectSum Op (a + b) c) => Op (a + (b + c)) ((a + b) + c) Source #

coRegroup' :: (Object Op a, Object Op c, ObjectSum Op a b, ObjectSum Op b c, ObjectSum Op a (b + c), ObjectSum Op (a + b) c) => Op ((a + b) + c) (a + (b + c)) Source #

maybeAsSum :: (ObjectSum Op u a, u ~ UnitObject Op, Object Op (Maybe a)) => Op (Maybe a) (u + a) Source #

maybeFromSum :: (ObjectSum Op u a, u ~ UnitObject Op, Object Op (Maybe a)) => Op (u + a) (Maybe a) Source #

boolAsSum :: (ObjectSum Op u u, u ~ UnitObject Op, Object Op Bool) => Op Bool (u + u) Source #

boolFromSum :: (ObjectSum Op u u, u ~ UnitObject Op, Object Op Bool) => Op (u + u) Bool Source #

(CoCartesian f, o (ZeroObject f)) => CoCartesian (o f) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type SumObjects (o f) a b Source #

type ZeroObject (o f) Source #

Methods

coSwap :: (ObjectSum (o f) a b, ObjectSum (o f) b a) => (o f) (a + b) (b + a) Source #

attachZero :: (Object (o f) a, zero ~ ZeroObject (o f), ObjectSum (o f) a zero) => (o f) a (a + zero) Source #

detachZero :: (Object (o f) a, zero ~ ZeroObject (o f), ObjectSum (o f) a zero) => (o f) (a + zero) a Source #

coRegroup :: (Object (o f) a, Object (o f) c, ObjectSum (o f) a b, ObjectSum (o f) b c, ObjectSum (o f) a (b + c), ObjectSum (o f) (a + b) c) => (o f) (a + (b + c)) ((a + b) + c) Source #

coRegroup' :: (Object (o f) a, Object (o f) c, ObjectSum (o f) a b, ObjectSum (o f) b c, ObjectSum (o f) a (b + c), ObjectSum (o f) (a + b) c) => (o f) ((a + b) + c) (a + (b + c)) Source #

maybeAsSum :: (ObjectSum (o f) u a, u ~ UnitObject (o f), Object (o f) (Maybe a)) => (o f) (Maybe a) (u + a) Source #

maybeFromSum :: (ObjectSum (o f) u a, u ~ UnitObject (o f), Object (o f) (Maybe a)) => (o f) (u + a) (Maybe a) Source #

boolAsSum :: (ObjectSum (o f) u u, u ~ UnitObject (o f), Object (o f) Bool) => (o f) Bool (u + u) Source #

boolFromSum :: (ObjectSum (o f) u u, u ~ UnitObject (o f), Object (o f) Bool) => (o f) (u + u) Bool Source #

(Monad m k, CoCartesian k, Object k (m (ZeroObject k)), Object k (m (m (ZeroObject k)))) => CoCartesian (Kleisli m k) Source # 
Instance details

Defined in Control.Monad.Constrained

Associated Types

type SumObjects (Kleisli m k) a b Source #

type ZeroObject (Kleisli m k) Source #

Methods

coSwap :: (ObjectSum (Kleisli m k) a b, ObjectSum (Kleisli m k) b a) => Kleisli m k (a + b) (b + a) Source #

attachZero :: (Object (Kleisli m k) a, zero ~ ZeroObject (Kleisli m k), ObjectSum (Kleisli m k) a zero) => Kleisli m k a (a + zero) Source #

detachZero :: (Object (Kleisli m k) a, zero ~ ZeroObject (Kleisli m k), ObjectSum (Kleisli m k) a zero) => Kleisli m k (a + zero) a Source #

coRegroup :: (Object (Kleisli m k) a, Object (Kleisli m k) c, ObjectSum (Kleisli m k) a b, ObjectSum (Kleisli m k) b c, ObjectSum (Kleisli m k) a (b + c), ObjectSum (Kleisli m k) (a + b) c) => Kleisli m k (a + (b + c)) ((a + b) + c) Source #

coRegroup' :: (Object (Kleisli m k) a, Object (Kleisli m k) c, ObjectSum (Kleisli m k) a b, ObjectSum (Kleisli m k) b c, ObjectSum (Kleisli m k) a (b + c), ObjectSum (Kleisli m k) (a + b) c) => Kleisli m k ((a + b) + c) (a + (b + c)) Source #

maybeAsSum :: (ObjectSum (Kleisli m k) u a, u ~ UnitObject (Kleisli m k), Object (Kleisli m k) (Maybe a)) => Kleisli m k (Maybe a) (u + a) Source #

maybeFromSum :: (ObjectSum (Kleisli m k) u a, u ~ UnitObject (Kleisli m k), Object (Kleisli m k) (Maybe a)) => Kleisli m k (u + a) (Maybe a) Source #

boolAsSum :: (ObjectSum (Kleisli m k) u u, u ~ UnitObject (Kleisli m k), Object (Kleisli m k) Bool) => Kleisli m k Bool (u + u) Source #

boolFromSum :: (ObjectSum (Kleisli m k) u u, u ~ UnitObject (Kleisli m k), Object (Kleisli m k) Bool) => Kleisli m k (u + u) Bool Source #

CoCartesian (->) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type SumObjects (->) a b Source #

type ZeroObject (->) Source #

Methods

coSwap :: (ObjectSum (->) a b, ObjectSum (->) b a) => (a + b) -> (b + a) Source #

attachZero :: (Object (->) a, zero ~ ZeroObject (->), ObjectSum (->) a zero) => a -> (a + zero) Source #

detachZero :: (Object (->) a, zero ~ ZeroObject (->), ObjectSum (->) a zero) => (a + zero) -> a Source #

coRegroup :: (Object (->) a, Object (->) c, ObjectSum (->) a b, ObjectSum (->) b c, ObjectSum (->) a (b + c), ObjectSum (->) (a + b) c) => (a + (b + c)) -> ((a + b) + c) Source #

coRegroup' :: (Object (->) a, Object (->) c, ObjectSum (->) a b, ObjectSum (->) b c, ObjectSum (->) a (b + c), ObjectSum (->) (a + b) c) => ((a + b) + c) -> (a + (b + c)) Source #

maybeAsSum :: (ObjectSum (->) u a, u ~ UnitObject (->), Object (->) (Maybe a)) => Maybe a -> (u + a) Source #

maybeFromSum :: (ObjectSum (->) u a, u ~ UnitObject (->), Object (->) (Maybe a)) => (u + a) -> Maybe a Source #

boolAsSum :: (ObjectSum (->) u u, u ~ UnitObject (->), Object (->) Bool) => Bool -> (u + u) Source #

boolFromSum :: (ObjectSum (->) u u, u ~ UnitObject (->), Object (->) Bool) => (u + u) -> Bool Source #

type ObjectSum k a b = (Category k, Object k a, Object k b, SumObjects k a b, Object k (a + b)) Source #

The standard function category

type Hask = Unconstrained (->) Source #

The category of all Haskell types, with (wrapped) Haskell functions as morphisms. This is just a type-wrapper, morally equivalent to the (->) category itself. The difference is that Functor instances in the (->) category are automatically inherited from the standard Functor instances that most packages define their type for. The benefit of that is that normal Haskell code keeps working when the Prelude classes are replaced with the ones from this library, but the downside is that you can't make more gradual instances when this is desired. This is where the Hask category comes in: it only has functors that are explicitly declared as such.

Isomorphisms

class Category k => Isomorphic k a b where Source #

Apart from the identity morphism, id, there are other morphisms that can basically be considered identies. For instance, in any cartesian category (where it makes sense to have tuples and unit () at all), it should be possible to switch between a and the isomorphic (a, ()). iso is the method for such "pseudo-identities", the most basic of which are required as methods of the Cartesian class.

Why it is necessary to make these morphisms explicit: they are needed for a couple of general-purpose category-theory methods, but even though they're normally trivial to define there is no uniform way to do so. For instance, for vector spaces, the baseis of (a, (b,c)) and ((a,b), c) are sure enough structurally equivalent, but not in the same way the spaces themselves are (sum vs. product types).

Methods

iso :: k a b Source #

Deprecated: This generic method, while looking nicely uniform, relies on OverlappingInstances and is therefore probably a bad idea. Use the specialised methods in classes like SPDistribute instead.

Instances

Instances details
(CoCartesian k, Object k a, u ~ ZeroObject k, ObjectSum k a u) => Isomorphic (k :: Type -> Type -> Type) (a :: Type) (a + u :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k a (a + u) Source #

(CoCartesian k, Object k a, u ~ ZeroObject k, ObjectSum k a u, ObjectSum k u a, Object k (u + a), Object k (a + u)) => Isomorphic (k :: Type -> Type -> Type) (a :: Type) (u + a :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k a (u + a) Source #

(Cartesian k, Object k a, u ~ UnitObject k, ObjectPair k a u) => Isomorphic (k :: Type -> Type -> Type) (a :: Type) ((a, u) :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k a (a, u) Source #

(Cartesian k, Object k a, u ~ UnitObject k, ObjectPair k a u, ObjectPair k u a, Object k (u, a), Object k (a, u)) => Isomorphic (k :: Type -> Type -> Type) (a :: Type) ((u, a) :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k a (u, a) Source #

(CoCartesian k, Object k a, u ~ ZeroObject k, ObjectSum k a u) => Isomorphic (k :: Type -> Type -> Type) (a + u :: Type) (a :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k (a + u) a Source #

(CoCartesian k, Object k a, u ~ ZeroObject k, ObjectSum k a u, ObjectSum k u a, Object k (u + a), Object k (a + u)) => Isomorphic (k :: Type -> Type -> Type) (u + a :: Type) (a :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k (u + a) a Source #

(Cartesian k, Object k a, u ~ UnitObject k, ObjectPair k a u) => Isomorphic (k :: Type -> Type -> Type) ((a, u) :: Type) (a :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k (a, u) a Source #

(Cartesian k, Object k a, u ~ UnitObject k, ObjectPair k a u, ObjectPair k u a, Object k (u, a), Object k (a, u)) => Isomorphic (k :: Type -> Type -> Type) ((u, a) :: Type) (a :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k (u, a) a Source #

(CoCartesian k, Object k a, ObjectSum k a b, ObjectSum k b c, ObjectSum k a (b + c), ObjectSum k (a + b) c, Object k c) => Isomorphic (k :: Type -> Type -> Type) ((a + b) + c :: Type) (a + (b + c) :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k ((a + b) + c) (a + (b + c)) Source #

(SPDistribute k, ObjectSum k (a, b) (a, c), ObjectPair k a (b + c), ObjectSum k b c, PairObjects k a b, PairObjects k a c) => Isomorphic (k :: Type -> Type -> Type) ((a, b) + (a, c) :: Type) ((a, b + c) :: Type) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

iso :: k ((a, b) + (a, c)) (a, b + c) Source #

(CoCartesian k, Object k a, ObjectSum k a b, ObjectSum k b c, ObjectSum k a (b + c), ObjectSum k (a + b) c, Object k c) => Isomorphic (k :: Type -> Type -> Type) (a + (b + c) :: Type) ((a + b) + c :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k (a + (b + c)) ((a + b) + c) Source #

(SPDistribute k, ObjectSum k a a, ObjectPair k Bool a) => Isomorphic (k :: Type -> Type -> Type) (a + a :: Type) ((Bool, a) :: Type) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

iso :: k (a + a) (Bool, a) Source #

(Cartesian k, Object k a, ObjectPair k a b, ObjectPair k b c, ObjectPair k a (b, c), ObjectPair k (a, b) c, Object k c) => Isomorphic (k :: Type -> Type -> Type) (((a, b), c) :: Type) ((a, (b, c)) :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k ((a, b), c) (a, (b, c)) Source #

(SPDistribute k, ObjectSum k a a, ObjectPair k Bool a) => Isomorphic (k :: Type -> Type -> Type) ((Bool, a) :: Type) (a + a :: Type) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

iso :: k (Bool, a) (a + a) Source #

(SPDistribute k, ObjectSum k (a, b) (a, c), ObjectPair k a (b + c), ObjectSum k b c, PairObjects k a b, PairObjects k a c) => Isomorphic (k :: Type -> Type -> Type) ((a, b + c) :: Type) ((a, b) + (a, c) :: Type) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

iso :: k (a, b + c) ((a, b) + (a, c)) Source #

(Cartesian k, Object k a, ObjectPair k a b, ObjectPair k b c, ObjectPair k a (b, c), ObjectPair k (a, b) c, Object k c) => Isomorphic (k :: Type -> Type -> Type) ((a, (b, c)) :: Type) (((a, b), c) :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

Methods

iso :: k (a, (b, c)) ((a, b), c) Source #

Constraining a category

newtype ConstrainedCategory (k :: * -> * -> *) (o :: * -> Constraint) (a :: *) (b :: *) Source #

A given category can be specialised, by using the same morphisms but adding extra constraints to what is considered an object.

For instance, Ord⊢(->) is the category of all totally ordered data types (but with arbitrary functions; this does not require monotonicity or anything).

Constructors

ConstrainedMorphism (k a b) 

Instances

Instances details
Category k => Category (isObj k :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type Object (isObj k) o Source #

Methods

id :: forall (a :: κ). Object (isObj k) a => (isObj k) a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (isObj k) a, Object (isObj k) b, Object (isObj k) c) => (isObj k) b c -> (isObj k) a b -> (isObj k) a c Source #

Functor [] k k => Functor [] (o k) (o k) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

fmap :: (Object (o k) a, Object (o k) [a], Object (o k) b, Object (o k) [b]) => (o k) a b -> (o k) [a] [b] Source #

(o (), o Void, o [Void]) => SumToProduct [] (o (->)) (o (->)) Source # 
Instance details

Defined in Control.Functor.Constrained

Methods

sum2product :: (ObjectSum (o (->)) a b, ObjectPair (o (->)) [a] [b]) => (o (->)) [a + b] ([a], [b]) Source #

mapEither :: (Object (o (->)) a, ObjectSum (o (->)) b c, Object (o (->)) [a], ObjectPair (o (->)) [b] [c]) => (o (->)) a (b + c) -> (o (->)) [a] ([b], [c]) Source #

filter :: (Object (o (->)) a, Object (o (->)) Bool, Object (o (->)) [a]) => (o (->)) a Bool -> (o (->)) [a] [a] Source #

(Foldable f s t, WellPointed s, WellPointed t, Functor f (o s) (o t)) => Foldable f (o s) (o t) Source # 
Instance details

Defined in Data.Foldable.Constrained

Methods

ffoldl :: (ObjectPair (o s) a b, ObjectPair (o t) a (f b)) => (o s) (a, b) a -> (o t) (a, f b) a Source #

foldMap :: (Object (o s) a, Object (o t) (f a), Semigroup m, Monoid m, Object (o s) m, Object (o t) m) => (o s) a m -> (o t) (f a) m Source #

EnhancedCat (Discrete :: Type -> Type -> Type) f => EnhancedCat (Discrete :: Type -> Type -> Type) (o f) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

arr :: (Object (o f) b, Object (o f) c, Object Discrete b, Object Discrete c) => (o f) b c -> Discrete b c Source #

(MorphChoice k, o (ZeroObject k)) => MorphChoice (o k) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

left :: (ObjectSum (o k) b d, ObjectSum (o k) c d) => (o k) b c -> (o k) (b + d) (c + d) Source #

right :: (ObjectSum (o k) d b, ObjectSum (o k) d c) => (o k) b c -> (o k) (d + b) (d + c) Source #

(+++) :: (ObjectSum (o k) b b', ObjectSum (o k) c c') => (o k) b c -> (o k) b' c' -> (o k) (b + b') (c + c') Source #

(Morphism a, o (UnitObject a)) => Morphism (o a) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

first :: (ObjectPair (o a) b d, ObjectPair (o a) c d) => (o a) b c -> (o a) (b, d) (c, d) Source #

second :: (ObjectPair (o a) d b, ObjectPair (o a) d c) => (o a) b c -> (o a) (d, b) (d, c) Source #

(***) :: (ObjectPair (o a) b b', ObjectPair (o a) c c') => (o a) b c -> (o a) b' c' -> (o a) (b, b') (c, c') Source #

(PreArrChoice k, o (ZeroObject k)) => PreArrChoice (o k) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

(|||) :: (ObjectSum (o k) b b', Object (o k) c) => (o k) b c -> (o k) b' c -> (o k) (b + b') c Source #

initial :: Object (o k) b => (o k) (ZeroObject (o k)) b Source #

coFst :: ObjectSum (o k) a b => (o k) a (a + b) Source #

coSnd :: ObjectSum (o k) a b => (o k) b (a + b) Source #

(PreArrow a, o (UnitObject a)) => PreArrow (o a) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

(&&&) :: (Object (o a) b, ObjectPair (o a) c c') => (o a) b c -> (o a) b c' -> (o a) b (c, c') Source #

terminal :: Object (o a) b => (o a) b (UnitObject (o a)) Source #

fst :: ObjectPair (o a) x y => (o a) (x, y) x Source #

snd :: ObjectPair (o a) x y => (o a) (x, y) y Source #

(SPDistribute k, o (ZeroObject k), o (UnitObject k)) => SPDistribute (o k) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

distribute :: (ObjectSum (o k) (a, b) (a, c), ObjectPair (o k) a (b + c), ObjectSum (o k) b c, PairObjects (o k) a b, PairObjects (o k) a c) => (o k) (a, b + c) ((a, b) + (a, c)) Source #

unDistribute :: (ObjectSum (o k) (a, b) (a, c), ObjectPair (o k) a (b + c), ObjectSum (o k) b c, PairObjects (o k) a b, PairObjects (o k) a c) => (o k) ((a, b) + (a, c)) (a, b + c) Source #

boolAsSwitch :: (ObjectSum (o k) a a, ObjectPair (o k) Bool a) => (o k) (Bool, a) (a + a) Source #

boolFromSwitch :: (ObjectSum (o k) a a, ObjectPair (o k) Bool a) => (o k) (a + a) (Bool, a) Source #

(WellPointed a, o (UnitObject a)) => WellPointed (o a) Source # 
Instance details

Defined in Control.Arrow.Constrained

Associated Types

type PointObject (o a) x Source #

Methods

globalElement :: ObjectPoint (o a) x => x -> (o a) (UnitObject (o a)) x Source #

unit :: CatTagged (o a) (UnitObject (o a)) Source #

const :: (Object (o a) b, ObjectPoint (o a) x) => x -> (o a) b x Source #

(Cartesian f, o (UnitObject f)) => Cartesian (o f) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type PairObjects (o f) a b Source #

type UnitObject (o f) Source #

Methods

swap :: (ObjectPair (o f) a b, ObjectPair (o f) b a) => (o f) (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject (o f), ObjectPair (o f) a unit) => (o f) a (a, unit) Source #

detachUnit :: (unit ~ UnitObject (o f), ObjectPair (o f) a unit) => (o f) (a, unit) a Source #

regroup :: (ObjectPair (o f) a b, ObjectPair (o f) b c, ObjectPair (o f) a (b, c), ObjectPair (o f) (a, b) c) => (o f) (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair (o f) a b, ObjectPair (o f) b c, ObjectPair (o f) a (b, c), ObjectPair (o f) (a, b) c) => (o f) ((a, b), c) (a, (b, c)) Source #

(CoCartesian f, o (ZeroObject f)) => CoCartesian (o f) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type SumObjects (o f) a b Source #

type ZeroObject (o f) Source #

Methods

coSwap :: (ObjectSum (o f) a b, ObjectSum (o f) b a) => (o f) (a + b) (b + a) Source #

attachZero :: (Object (o f) a, zero ~ ZeroObject (o f), ObjectSum (o f) a zero) => (o f) a (a + zero) Source #

detachZero :: (Object (o f) a, zero ~ ZeroObject (o f), ObjectSum (o f) a zero) => (o f) (a + zero) a Source #

coRegroup :: (Object (o f) a, Object (o f) c, ObjectSum (o f) a b, ObjectSum (o f) b c, ObjectSum (o f) a (b + c), ObjectSum (o f) (a + b) c) => (o f) (a + (b + c)) ((a + b) + c) Source #

coRegroup' :: (Object (o f) a, Object (o f) c, ObjectSum (o f) a b, ObjectSum (o f) b c, ObjectSum (o f) a (b + c), ObjectSum (o f) (a + b) c) => (o f) ((a + b) + c) (a + (b + c)) Source #

maybeAsSum :: (ObjectSum (o f) u a, u ~ UnitObject (o f), Object (o f) (Maybe a)) => (o f) (Maybe a) (u + a) Source #

maybeFromSum :: (ObjectSum (o f) u a, u ~ UnitObject (o f), Object (o f) (Maybe a)) => (o f) (u + a) (Maybe a) Source #

boolAsSum :: (ObjectSum (o f) u u, u ~ UnitObject (o f), Object (o f) Bool) => (o f) Bool (u + u) Source #

boolFromSum :: (ObjectSum (o f) u u, u ~ UnitObject (o f), Object (o f) Bool) => (o f) (u + u) Bool Source #

(Curry f, o (UnitObject f)) => Curry (o f) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type MorphObjects (o f) b c Source #

Methods

uncurry :: (ObjectPair (o f) a b, ObjectMorphism (o f) b c) => (o f) a ((o f) b c) -> (o f) (a, b) c Source #

curry :: (ObjectPair (o f) a b, ObjectMorphism (o f) b c) => (o f) (a, b) c -> (o f) a ((o f) b c) Source #

apply :: (ObjectMorphism (o f) a b, ObjectPair (o f) ((o f) a b) a) => (o f) ((o f) a b, a) b Source #

(EnhancedCat a k, o (UnitObject a)) => EnhancedCat (o a) k Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

arr :: (Object k b, Object k c, Object (o a) b, Object (o a) c) => k b c -> (o a) b c Source #

Category f => EnhancedCat (o f) (Discrete :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

arr :: (Object Discrete b, Object Discrete c, Object (o f) b, Object (o f) c) => Discrete b c -> (o f) b c Source #

Function f => EnhancedCat (->) (o f) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

arr :: (Object (o f) b, Object (o f) c, Object (->) b, Object (->) c) => (o f) b c -> b -> c Source #

type Object (isObj k :: Type -> Type -> Type) (o :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

type Object (isObj k :: Type -> Type -> Type) (o :: Type) = (Object k o, isObj o)
type UnitObject (o f) Source # 
Instance details

Defined in Control.Category.Constrained

type UnitObject (o f) = UnitObject f
type ZeroObject (o f) Source # 
Instance details

Defined in Control.Category.Constrained

type ZeroObject (o f) = ZeroObject f
type PointObject (o a) x Source # 
Instance details

Defined in Control.Arrow.Constrained

type PointObject (o a) x = PointObject a x
type MorphObjects (o f) a c Source # 
Instance details

Defined in Control.Category.Constrained

type MorphObjects (o f) a c = (MorphObjects f a c, f ~ (->))
type PairObjects (o f) a b Source # 
Instance details

Defined in Control.Category.Constrained

type PairObjects (o f) a b = PairObjects f a b
type SumObjects (o f) a b Source # 
Instance details

Defined in Control.Category.Constrained

type SumObjects (o f) a b = SumObjects f a b

constrained :: forall o k a b. (Category k, o a, o b) => k a b -> (o k) a b Source #

Cast a morphism to its equivalent in a more constrained category, provided it connects objects that actually satisfy the extra constraint.

In practice, it is often necessary to specify to what typeclass it should be constrained. The most convenient way of doing that is with type-applications syntax. E.g. constrained @Ord length is the length function considered as a morphism in the subcategory of Hask in which all types are orderable. (Which makes it suitable for e.g. fmapping over a set.)

unconstrained :: forall o k a b. Category k => (o k) a b -> k a b Source #

"Unpack" a constrained morphism again (forgetful functor).

Note that you may often not need to do that; in particular morphisms that are actually Functions can just be applied to their objects with $ right away, no need to go back to Hask first.

Product categories

data ProductCategory k l p q Source #

Constructors

(k (LFactor p) (LFactor q)) :***: (l (RFactor p) (RFactor q)) infixr 3 

Instances

Instances details
(Category k, Category l) => Category (k × l :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type Object (k × l) o Source #

Methods

id :: forall (a :: κ). Object (k × l) a => (k × l) a a Source #

(.) :: forall (a :: κ) (b :: κ) (c :: κ). (Object (k × l) a, Object (k × l) b, Object (k × l) c) => (k × l) b c -> (k × l) a b -> (k × l) a c Source #

(Morphism k, Morphism l) => Morphism (k × l) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

first :: (ObjectPair (k × l) b d, ObjectPair (k × l) c d) => (k × l) b c -> (k × l) (b, d) (c, d) Source #

second :: (ObjectPair (k × l) d b, ObjectPair (k × l) d c) => (k × l) b c -> (k × l) (d, b) (d, c) Source #

(***) :: (ObjectPair (k × l) b b', ObjectPair (k × l) c c') => (k × l) b c -> (k × l) b' c' -> (k × l) (b, b') (c, c') Source #

(PreArrow k, PreArrow l) => PreArrow (k × l) Source # 
Instance details

Defined in Control.Arrow.Constrained

Methods

(&&&) :: (Object (k × l) b, ObjectPair (k × l) c c') => (k × l) b c -> (k × l) b c' -> (k × l) b (c, c') Source #

terminal :: Object (k × l) b => (k × l) b (UnitObject (k × l)) Source #

fst :: ObjectPair (k × l) x y => (k × l) (x, y) x Source #

snd :: ObjectPair (k × l) x y => (k × l) (x, y) y Source #

(WellPointed k, WellPointed l) => WellPointed (k × l) Source # 
Instance details

Defined in Control.Arrow.Constrained

Associated Types

type PointObject (k × l) x Source #

Methods

globalElement :: ObjectPoint (k × l) x => x -> (k × l) (UnitObject (k × l)) x Source #

unit :: CatTagged (k × l) (UnitObject (k × l)) Source #

const :: (Object (k × l) b, ObjectPoint (k × l) x) => x -> (k × l) b x Source #

(Cartesian k, Cartesian l) => Cartesian (k × l) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type PairObjects (k × l) a b Source #

type UnitObject (k × l) Source #

Methods

swap :: (ObjectPair (k × l) a b, ObjectPair (k × l) b a) => (k × l) (a, b) (b, a) Source #

attachUnit :: (unit ~ UnitObject (k × l), ObjectPair (k × l) a unit) => (k × l) a (a, unit) Source #

detachUnit :: (unit ~ UnitObject (k × l), ObjectPair (k × l) a unit) => (k × l) (a, unit) a Source #

regroup :: (ObjectPair (k × l) a b, ObjectPair (k × l) b c, ObjectPair (k × l) a (b, c), ObjectPair (k × l) (a, b) c) => (k × l) (a, (b, c)) ((a, b), c) Source #

regroup' :: (ObjectPair (k × l) a b, ObjectPair (k × l) b c, ObjectPair (k × l) a (b, c), ObjectPair (k × l) (a, b) c) => (k × l) ((a, b), c) (a, (b, c)) Source #

type Object (k × l :: Type -> Type -> Type) (o :: Type) Source # 
Instance details

Defined in Control.Category.Constrained

type Object (k × l :: Type -> Type -> Type) (o :: Type) = (IsProduct o, Object k (LFactor o), Object l (RFactor o))
type UnitObject (k × l) Source # 
Instance details

Defined in Control.Category.Constrained

type PointObject (k × l) o Source # 
Instance details

Defined in Control.Arrow.Constrained

type PointObject (k × l) o = (PointObject k (LFactor o), PointObject l (RFactor o))
type PairObjects (k × l) a b Source # 
Instance details

Defined in Control.Category.Constrained

type PairObjects (k × l) a b = (PairObjects k (LFactor a) (LFactor b), PairObjects l (RFactor a) (RFactor b))

Global-element proxies

class Category k => HasAgent k where Source #

An agent value is a "general representation" of a category's values, i.e. global elements. This is useful to define certain morphisms (including ones that can't just "inherit" from -> with arr) in ways other than point-free composition pipelines. Instead, you can write algebraic expressions much as if dealing with actual values of your category's objects, but using the agent type which is restricted so any function defined as such a lambda-expression qualifies as a morphism of that category.

Associated Types

type AgentVal k a v :: * Source #

type AgentVal k a v = GenericAgent k a v

Methods

alg :: (Object k a, Object k b) => (forall q. Object k q => AgentVal k q a -> AgentVal k q b) -> k a b Source #

($~) :: (Object k a, Object k b, Object k c) => k b c -> AgentVal k a b -> AgentVal k a c infixr 0 Source #

Instances

Instances details
(HasAgent k, Cartesian k) => HasAgent (ReCartesian k) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type AgentVal (ReCartesian k) a v Source #

Methods

alg :: (Object (ReCartesian k) a, Object (ReCartesian k) b) => (forall q. Object (ReCartesian k) q => AgentVal (ReCartesian k) q a -> AgentVal (ReCartesian k) q b) -> ReCartesian k a b Source #

($~) :: (Object (ReCartesian k) a, Object (ReCartesian k) b, Object (ReCartesian k) c) => ReCartesian k b c -> AgentVal (ReCartesian k) a b -> AgentVal (ReCartesian k) a c Source #

HasAgent k => HasAgent (ReCategory k) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type AgentVal (ReCategory k) a v Source #

Methods

alg :: (Object (ReCategory k) a, Object (ReCategory k) b) => (forall q. Object (ReCategory k) q => AgentVal (ReCategory k) q a -> AgentVal (ReCategory k) q b) -> ReCategory k a b Source #

($~) :: (Object (ReCategory k) a, Object (ReCategory k) b, Object (ReCategory k) c) => ReCategory k b c -> AgentVal (ReCategory k) a b -> AgentVal (ReCategory k) a c Source #

(HasAgent k, Morphism k) => HasAgent (ReMorphism k) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type AgentVal (ReMorphism k) a v Source #

Methods

alg :: (Object (ReMorphism k) a, Object (ReMorphism k) b) => (forall q. Object (ReMorphism k) q => AgentVal (ReMorphism k) q a -> AgentVal (ReMorphism k) q b) -> ReMorphism k a b Source #

($~) :: (Object (ReMorphism k) a, Object (ReMorphism k) b, Object (ReMorphism k) c) => ReMorphism k b c -> AgentVal (ReMorphism k) a b -> AgentVal (ReMorphism k) a c Source #

(HasAgent k, PreArrow k) => HasAgent (RePreArrow k) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type AgentVal (RePreArrow k) a v Source #

Methods

alg :: (Object (RePreArrow k) a, Object (RePreArrow k) b) => (forall q. Object (RePreArrow k) q => AgentVal (RePreArrow k) q a -> AgentVal (RePreArrow k) q b) -> RePreArrow k a b Source #

($~) :: (Object (RePreArrow k) a, Object (RePreArrow k) b, Object (RePreArrow k) c) => RePreArrow k b c -> AgentVal (RePreArrow k) a b -> AgentVal (RePreArrow k) a c Source #

(HasAgent k, WellPointed k) => HasAgent (ReWellPointed k) Source # 
Instance details

Defined in Control.Category.Constrained.Reified

Associated Types

type AgentVal (ReWellPointed k) a v Source #

HasAgent (Discrete :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type AgentVal Discrete a v Source #

HasAgent (->) Source # 
Instance details

Defined in Control.Category.Constrained

Associated Types

type AgentVal (->) a v Source #

Methods

alg :: (Object (->) a, Object (->) b) => (forall q. Object (->) q => AgentVal (->) q a -> AgentVal (->) q b) -> a -> b Source #

($~) :: (Object (->) a, Object (->) b, Object (->) c) => (b -> c) -> AgentVal (->) a b -> AgentVal (->) a c Source #

genericAlg :: (HasAgent k, Object k a, Object k b) => (forall q. Object k q => GenericAgent k q a -> GenericAgent k q b) -> k a b Source #

genericAgentMap :: (HasAgent k, Object k a, Object k b, Object k c) => k b c -> GenericAgent k a b -> GenericAgent k a c Source #

data GenericAgent k a v Source #

Constructors

GenericAgent 

Fields

Utility

inCategoryOf :: Category k => k a b -> k c d -> k a b Source #

Analogue to asTypeOf, this does not actually do anything but can give the compiler type unification hints in a convenient manner.

type CatTagged k x = Tagged (k (UnitObject k) (UnitObject k)) x Source #

Tagged type for values that depend on some choice of category, but not on some particular object / arrow therein.