Copyright | (c) Eitan Chatav 2019 |
---|---|
Maintainer | eitan@morphism.tech |
Stability | experimental |
Safe Haskell | Safe |
Language | Haskell2010 |
Consider the category of Haskell Category
s, a subcategory
of the category of quivers with,
- constrained objects
Category
c => c
- morphisms are functors (which preserve objects)
t :: (Category c, Category d) => c x y -> d x y
t id = id
t (g . f) = t g . t f
Thus, a functor from quivers to Category
s
has (QFunctor c, forall p. Category (c p))
with.
qmap f id = id
qmap f (q . p) = qmap f q . qmap f p
The free category functor
from quivers to Category
s may be defined up to isomorphism as
Synopsis
- data Path p x y where
- pattern (:<<) :: Path p y z -> p x y -> Path p x z
- newtype FoldPath p x y = FoldPath {
- getFoldPath :: forall q. Category q => (forall x y. p x y -> q x y) -> q x y
- class (QPointed c, QFoldable c, forall p. Category (c p)) => CFree c
- toPath :: (QFoldable c, CFree path) => c p x y -> path p x y
- reversePath :: (QFoldable c, CFree path) => c p x y -> path (OpQ p) y x
- beforeAll :: (QFoldable c, CFree path) => (forall x. p x x) -> c p x y -> path p x y
- afterAll :: (QFoldable c, CFree path) => (forall x. p x x) -> c p x y -> path p x y
- class Category (cat :: k -> k -> Type) where
Documentation
data Path p x y where Source #
A Path
with steps in p
is a singly linked list of
"type-aligned" constructions of p
.
>>>
:{
let path :: Path (->) String Int path = length :>> (\x -> x^2) :>> Done in qfold path "hello" :} 25
Instances
QFunctor (Path :: (k -> k -> Type) -> k -> k -> Type) Source # | |
QMonad (Path :: (k -> k -> Type) -> k -> k -> Type) Source # | |
QPointed (Path :: (k -> k -> Type) -> k -> k -> Type) Source # | |
Defined in Control.Category.Free | |
QTraversable (Path :: (k -> k -> Type) -> k -> k -> Type) Source # | |
Defined in Control.Category.Free | |
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 # | |
CFree (Path :: (k -> k -> Type) -> k -> k -> Type) Source # | |
Defined in Control.Category.Free | |
Category (Path p :: k -> k -> Type) Source # | |
(forall (x1 :: k) (y1 :: k). Show (p x1 y1)) => Show (Path p x y) Source # | |
x ~ y => Semigroup (Path p x y) Source # | |
x ~ y => Monoid (Path p x y) Source # | |
pattern (:<<) :: Path p y z -> p x y -> Path p x z infixl 7 Source #
The snoc pattern for right-to-left composition.
newtype FoldPath p x y Source #
Encodes a path as its qfoldMap
function.
FoldPath | |
|
Instances
QFunctor (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # | |
QMonad (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # | |
QPointed (FoldPath :: (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 | |
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 # | |
CFree (FoldPath :: (k -> k -> Type) -> k -> k -> Type) Source # | |
Defined in Control.Category.Free | |
Category (FoldPath p :: k -> k -> Type) Source # | |
x ~ y => Semigroup (FoldPath p x y) Source # | |
x ~ y => Monoid (FoldPath p x y) Source # | |
class (QPointed c, QFoldable c, forall p. Category (c p)) => CFree c Source #
reversePath :: (QFoldable c, CFree path) => c p x y -> path (OpQ p) y x Source #
Reverse all the arrows in a path.
beforeAll :: (QFoldable c, CFree path) => (forall x. p x x) -> c p x y -> path p x y Source #
Insert a given loop before each step.
afterAll :: (QFoldable c, CFree path) => (forall x. p x x) -> c p x y -> path p x y Source #
Insert a given loop before each step.
class Category (cat :: k -> k -> Type) where #
A class for categories. Instances should satisfy the laws
f.
id
= f -- (right identity)id
.
f = f -- (left identity) f.
(g.
h) = (f.
g).
h -- (associativity)
Instances
Category (Coercion :: k -> k -> Type) | Since: base-4.7.0.0 |
Category ((:~:) :: k -> k -> Type) | Since: base-4.7.0.0 |
Category c => Category (IsoQ c :: k -> k -> Type) Source # | |
Monoid m => Category (ReflQ m :: k -> k -> Type) Source # | |
Category ((:~~:) :: k -> k -> Type) | Since: base-4.10.0.0 |
Category (Path p :: k -> k -> Type) Source # | |
Category (FoldPath p :: k -> k -> Type) Source # | |
Category c => Category (IQ c :: k -> k -> Type) Source # | |
Category c => Category (OpQ c :: k -> k -> Type) Source # | |
Monoid m => Category (KQ m :: k -> k -> Type) Source # | |
(Category p, Category q) => Category (ProductQ p q :: k -> k -> Type) Source # | |
(Applicative m, Category c) => Category (ApQ m c :: k -> k -> Type) Source # | |
(Category p, p ~ q) => Category (ComposeQ p q :: k -> k -> Type) Source # | |
p ~ q => Category (LeftQ p q :: k2 -> k2 -> Type) Source # | |
p ~ q => Category (RightQ p q :: k1 -> k1 -> Type) Source # | |
Category ((->) :: Type -> Type -> Type) | Since: base-3.0 |
Defined in Control.Category |