Copyright | (c) Eitan Chatav 2019 |
---|---|
Maintainer | eitan@morphism.tech |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
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
- class QFunctor c where
- qmap :: (forall x y. p x y -> q x y) -> c p x y -> c q x y
- class QFunctor c => QPointed c where
- qsingle :: p x y -> c p x y
- class QFunctor c => QFoldable c where
- qfoldMap :: Category q => (forall x y. p x y -> q x y) -> c p x y -> q x y
- qfold :: Category q => c q x y -> q x y
- qfoldr :: (forall x y z. p x y -> q y z -> q x z) -> q y z -> c p x y -> q x z
- qfoldl :: (forall x y z. q x y -> p y z -> q x z) -> q x y -> c p y z -> q x z
- qtoMonoid :: Monoid m => (forall x y. p x y -> m) -> c p x y -> m
- qtoList :: (forall x y. p x y -> a) -> c p x y -> [a]
- qtraverse_ :: (Applicative m, Category q) => (forall x y. p x y -> m (q x y)) -> c p x y -> m (q x y)
- class QFoldable c => QTraversable c where
- qtraverse :: Applicative m => (forall x y. p x y -> m (q x y)) -> c p x y -> m (c q x y)
- class (QFunctor c, QPointed c) => QMonad c where
Documentation
class QFunctor c where Source #
An endfunctor of quivers.
qmap id = id
qmap (g . f) = qmap g . qmap f
Instances
QFunctor (IsoQ :: (k -> k -> Type) -> k -> k -> Type) Source # | |
QFunctor (Path :: (k -> k -> Type) -> k -> k -> Type) Source # | |
QFunctor (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # | |
QFunctor (IQ :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
QFunctor (OpQ :: (k2 -> k1 -> Type) -> k1 -> k2 -> Type) Source # | |
QFunctor (HomQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
QFunctor (ProductQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
QFunctor (RightQ p :: (k1 -> k3 -> Type) -> k1 -> k2 -> Type) Source # | |
QFunctor (LeftQ p :: (k2 -> k1 -> Type) -> k3 -> k1 -> Type) Source # | |
QFunctor (ComposeQ p :: (k1 -> k2 -> Type) -> k1 -> k3 -> Type) Source # | |
Functor t => QFunctor (ApQ t :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
class QFunctor c => QPointed c where Source #
Embed a single quiver arrow with qsingle
.
Instances
QPointed (Path :: (k -> k -> Type) -> k -> k -> Type) Source # | |
Defined in Control.Category.Free | |
QPointed (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # | |
Defined in Control.Category.Free | |
QPointed (IQ :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
Defined in Data.Quiver.Functor | |
QPointed (HomQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
Defined in Data.Quiver.Functor | |
Category p => QPointed (ComposeQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
Defined in Data.Quiver.Functor | |
Applicative t => QPointed (ApQ t :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
Defined in Data.Quiver.Functor |
class QFunctor c => QFoldable c where Source #
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 Path
s,
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 Path
s,
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 # | |
Defined in Control.Category.Free 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 # | |
Defined in Control.Category.Free 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 # | |
Defined in Data.Quiver.Functor 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 # | |
Defined in Data.Quiver.Functor 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.
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 # | |
Defined in Control.Category.Free | |
QTraversable (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # | |
Defined in Control.Category.Free | |
QTraversable (IQ :: (k -> k -> Type) -> k -> k -> Type) Source # | |
Defined in Data.Quiver.Functor | |
QTraversable (ProductQ p :: (k -> k -> Type) -> k -> k -> Type) Source # | |
Defined in Data.Quiver.Functor |
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)
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 # | |
QMonad (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # | |
QMonad (IQ :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
QMonad (HomQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
Category p => QMonad (ComposeQ p :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |
Monad t => QMonad (ApQ t :: (k1 -> k2 -> Type) -> k1 -> k2 -> Type) Source # | |