free-categories-0.2.0.2: free categories

Copyright(c) Eitan Chatav 2019
Maintainereitan@morphism.tech
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Data.Quiver.Functor

Description

Consider the category of Haskell quivers with

  • objects are types of higher kind
  • p :: k -> k -> Type
  • morphisms are terms of RankNType,
  • forall x y. p x y -> q x y
  • identity is id
  • composition is .

There is a natural hierarchy of typeclasses for endofunctors of the category of Haskell quivers, analagous to that for Haskell types.

Synopsis

Documentation

class QFunctor c where Source #

An endfunctor of quivers.

qmap id = id
qmap (g . f) = qmap g . qmap f

Methods

qmap :: (forall x y. p x y -> q x y) -> c p x y -> c q x y Source #

Instances
QFunctor (IsoQ :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qmap :: (forall (x :: k0) (y :: k1). p x y -> q x y) -> IsoQ p x y -> IsoQ q x y Source #

QFunctor (Path :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qmap :: (forall (x :: k0) (y :: k1). p x y -> q x y) -> Path p x y -> Path q x y Source #

QFunctor (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qmap :: (forall (x :: k0) (y :: k1). p x y -> q x y) -> FoldPath p x y -> FoldPath q x y Source #

QFunctor (IQ :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qmap :: (forall (x :: k) (y :: k). p x y -> q x y) -> IQ p x y -> IQ q x y Source #

QFunctor (OpQ :: (k2 -> k1 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qmap :: (forall (x :: k) (y :: k). p x y -> q x y) -> OpQ p x y -> OpQ q x y Source #

QFunctor (HomQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qmap :: (forall (x :: k) (y :: k). p0 x y -> q x y) -> HomQ p p0 x y -> HomQ p q x y Source #

QFunctor (ProductQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qmap :: (forall (x :: k) (y :: k). p0 x y -> q x y) -> ProductQ p p0 x y -> ProductQ p q x y Source #

QFunctor (RightQ p :: (k1 -> k3 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qmap :: (forall (x :: k) (y :: k). p0 x y -> q x y) -> RightQ p p0 x y -> RightQ p q x y Source #

QFunctor (LeftQ p :: (k2 -> k1 -> Type) -> k3 -> k1 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qmap :: (forall (x :: k) (y :: k). p0 x y -> q x y) -> LeftQ p p0 x y -> LeftQ p q x y Source #

QFunctor (ComposeQ p :: (k1 -> k2 -> Type) -> k1 -> k3 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qmap :: (forall (x :: k) (y :: k). p0 x y -> q x y) -> ComposeQ p p0 x y -> ComposeQ p q x y Source #

Functor t => QFunctor (ApQ t :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qmap :: (forall (x :: k) (y :: k). p x y -> q x y) -> ApQ t p x y -> ApQ t q x y Source #

class QFunctor c => QPointed c where Source #

Embed a single quiver arrow with qsingle.

Methods

qsingle :: p x y -> c p x y Source #

Instances
QPointed (Path :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qsingle :: p x y -> Path p x y Source #

QPointed (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qsingle :: p x y -> FoldPath p x y Source #

QPointed (IQ :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qsingle :: p x y -> IQ p x y Source #

QPointed (HomQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qsingle :: p0 x y -> HomQ p p0 x y Source #

Category p => QPointed (ComposeQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qsingle :: p0 x y -> ComposeQ p p0 x y Source #

Applicative t => QPointed (ApQ t :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qsingle :: p x y -> ApQ t p x y Source #

class QFunctor c => QFoldable c where Source #

Generalizing Foldable from Monoids to Categorys.

qmap f = qfoldMap (qsingle . f)

Minimal complete definition

qfoldMap

Methods

qfoldMap :: Category q => (forall x y. p x y -> q x y) -> c p x y -> q x y Source #

Map each element of the structure to a Category, and combine the results.

qfold :: Category q => c q x y -> q x y Source #

Combine the elements of a structure using a Category.

qfoldr :: (forall x y z. p x y -> q y z -> q x z) -> q y z -> c p x y -> q x z Source #

Right-associative fold of a structure.

In the case of Paths, qfoldr, when applied to a binary operator, a starting value, and a Path, reduces the Path using the binary operator, from right to left:

qfoldr (?) q (p1 :>> p2 :>> ... :>> pn :>> Done) == p1 ? (p2 ? ... (pn ? q) ...)

qfoldl :: (forall x y z. q x y -> p y z -> q x z) -> q x y -> c p y z -> q x z Source #

Left-associative fold of a structure.

In the case of Paths, qfoldl, when applied to a binary operator, a starting value, and a Path, reduces the Path using the binary operator, from left to right:

qfoldl (?) q (p1 :>> p2 :>> ... :>> pn :>> Done) == (... ((q ? p1) ? p2) ? ...) ? pn

qtoMonoid :: Monoid m => (forall x y. p x y -> m) -> c p x y -> m Source #

Map each element of the structure to a Monoid, and combine the results.

qtoList :: (forall x y. p x y -> a) -> c p x y -> [a] Source #

Map each element of the structure, and combine the results in a list.

qtraverse_ :: (Applicative m, Category q) => (forall x y. p x y -> m (q x y)) -> c p x y -> m (q x y) Source #

Map each element of a structure to an Applicative on a Category, evaluate from left to right, and combine the results.

Instances
QFoldable (Path :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qfoldMap :: Category q => (forall (x :: k0) (y :: k0). p x y -> q x y) -> Path p x y -> q x y Source #

qfold :: Category q => Path q x y -> q x y Source #

qfoldr :: (forall (x :: k0) (y :: k0) (z :: k1). p x y -> q y z -> q x z) -> q y z -> Path p x y -> q x z Source #

qfoldl :: (forall (x :: k0) (y :: k1) (z :: k1). q x y -> p y z -> q x z) -> q x y -> Path p y z -> q x z Source #

qtoMonoid :: Monoid m => (forall (x :: k0) (y :: k0). p x y -> m) -> Path p x y -> m Source #

qtoList :: (forall (x :: k0) (y :: k0). p x y -> a) -> Path p x y -> [a] Source #

qtraverse_ :: (Applicative m, Category q) => (forall (x :: k0) (y :: k0). p x y -> m (q x y)) -> Path p x y -> m (q x y) Source #

QFoldable (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qfoldMap :: Category q => (forall (x :: k0) (y :: k0). p x y -> q x y) -> FoldPath p x y -> q x y Source #

qfold :: Category q => FoldPath q x y -> q x y Source #

qfoldr :: (forall (x :: k0) (y :: k0) (z :: k1). p x y -> q y z -> q x z) -> q y z -> FoldPath p x y -> q x z Source #

qfoldl :: (forall (x :: k0) (y :: k1) (z :: k1). q x y -> p y z -> q x z) -> q x y -> FoldPath p y z -> q x z Source #

qtoMonoid :: Monoid m => (forall (x :: k0) (y :: k0). p x y -> m) -> FoldPath p x y -> m Source #

qtoList :: (forall (x :: k0) (y :: k0). p x y -> a) -> FoldPath p x y -> [a] Source #

qtraverse_ :: (Applicative m, Category q) => (forall (x :: k0) (y :: k0). p x y -> m (q x y)) -> FoldPath p x y -> m (q x y) Source #

QFoldable (IQ :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qfoldMap :: Category q => (forall (x :: k0) (y :: k0). p x y -> q x y) -> IQ p x y -> q x y Source #

qfold :: Category q => IQ q x y -> q x y Source #

qfoldr :: (forall (x :: k0) (y :: k0) (z :: k1). p x y -> q y z -> q x z) -> q y z -> IQ p x y -> q x z Source #

qfoldl :: (forall (x :: k0) (y :: k1) (z :: k1). q x y -> p y z -> q x z) -> q x y -> IQ p y z -> q x z Source #

qtoMonoid :: Monoid m => (forall (x :: k0) (y :: k0). p x y -> m) -> IQ p x y -> m Source #

qtoList :: (forall (x :: k0) (y :: k0). p x y -> a) -> IQ p x y -> [a] Source #

qtraverse_ :: (Applicative m, Category q) => (forall (x :: k0) (y :: k0). p x y -> m (q x y)) -> IQ p x y -> m (q x y) Source #

QFoldable (ProductQ p :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qfoldMap :: Category q => (forall (x :: k0) (y :: k0). p0 x y -> q x y) -> ProductQ p p0 x y -> q x y Source #

qfold :: Category q => ProductQ p q x y -> q x y Source #

qfoldr :: (forall (x :: k0) (y :: k0) (z :: k1). p0 x y -> q y z -> q x z) -> q y z -> ProductQ p p0 x y -> q x z Source #

qfoldl :: (forall (x :: k0) (y :: k1) (z :: k1). q x y -> p0 y z -> q x z) -> q x y -> ProductQ p p0 y z -> q x z Source #

qtoMonoid :: Monoid m => (forall (x :: k0) (y :: k0). p0 x y -> m) -> ProductQ p p0 x y -> m Source #

qtoList :: (forall (x :: k0) (y :: k0). p0 x y -> a) -> ProductQ p p0 x y -> [a] Source #

qtraverse_ :: (Applicative m, Category q) => (forall (x :: k0) (y :: k0). p0 x y -> m (q x y)) -> ProductQ p p0 x y -> m (q x y) Source #

class QFoldable c => QTraversable c where Source #

Generalizing Traversable to quivers.

Methods

qtraverse :: Applicative m => (forall x y. p x y -> m (q x y)) -> c p x y -> m (c q x y) Source #

Map each element of a structure to an Applicative on a quiver, evaluate from left to right, and collect the results.

Instances
QTraversable (Path :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qtraverse :: Applicative m => (forall (x :: k0) (y :: k0). p x y -> m (q x y)) -> Path p x y -> m (Path q x y) Source #

QTraversable (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qtraverse :: Applicative m => (forall (x :: k0) (y :: k0). p x y -> m (q x y)) -> FoldPath p x y -> m (FoldPath q x y) Source #

QTraversable (IQ :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qtraverse :: Applicative m => (forall (x :: k0) (y :: k0). p x y -> m (q x y)) -> IQ p x y -> m (IQ q x y) Source #

QTraversable (ProductQ p :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qtraverse :: Applicative m => (forall (x :: k0) (y :: k0). p0 x y -> m (q x y)) -> ProductQ p p0 x y -> m (ProductQ p q x y) Source #

class (QFunctor c, QPointed c) => QMonad c where Source #

Generalize Monad to quivers.

Associativity and left and right identity laws hold.

qjoin . qjoin = qjoin . qmap qjoin
qjoin . qsingle = id
qjoin . qmap qsingle = id

The functions qbind and qjoin are related as

qjoin = qbind id
qbind f p = qjoin (qmap f p)

Minimal complete definition

qjoin | qbind

Methods

qjoin :: c (c p) x y -> c p x y Source #

qbind :: (forall x y. p x y -> c q x y) -> c p x y -> c q x y Source #

Instances
QMonad (Path :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qjoin :: Path (Path p) x y -> Path p x y Source #

qbind :: (forall (x :: k0) (y :: k1). p x y -> Path q x y) -> Path p x y -> Path q x y Source #

QMonad (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # 
Instance details

Defined in Control.Category.Free

Methods

qjoin :: FoldPath (FoldPath p) x y -> FoldPath p x y Source #

qbind :: (forall (x :: k0) (y :: k1). p x y -> FoldPath q x y) -> FoldPath p x y -> FoldPath q x y Source #

QMonad (IQ :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qjoin :: IQ (IQ p) x y -> IQ p x y Source #

qbind :: (forall (x :: k) (y :: k). p x y -> IQ q x y) -> IQ p x y -> IQ q x y Source #

QMonad (HomQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qjoin :: HomQ p (HomQ p p0) x y -> HomQ p p0 x y Source #

qbind :: (forall (x :: k) (y :: k). p0 x y -> HomQ p q x y) -> HomQ p p0 x y -> HomQ p q x y Source #

Category p => QMonad (ComposeQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qjoin :: ComposeQ p (ComposeQ p p0) x y -> ComposeQ p p0 x y Source #

qbind :: (forall (x :: k) (y :: k). p0 x y -> ComposeQ p q x y) -> ComposeQ p p0 x y -> ComposeQ p q x y Source #

Monad t => QMonad (ApQ t :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # 
Instance details

Defined in Data.Quiver.Functor

Methods

qjoin :: ApQ t (ApQ t p) x y -> ApQ t p x y Source #

qbind :: (forall (x :: k) (y :: k). p x y -> ApQ t q x y) -> ApQ t p x y -> ApQ t q x y Source #