Copyright | (c) 2014 Justus Sagemüller |
---|---|
License | GPL v3 (see COPYING) |
Maintainer | (@) sagemueller $ geo.uni-koeln.de |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
- module Control.Category.Constrained
- class (Category r, Category t, Object t (f (UnitObject r))) => Functor f r t | f r -> t, f t -> r where
- (<$>) :: (Functor f r (->), Object r a, Object r b) => r a b -> f a -> f b
- constrainedFmap :: (Category r, Category t, o a, o b, o (f a), o (f b)) => (r a b -> t (f a) (f b)) -> ConstrainedCategory r o a b -> ConstrainedCategory t o (f a) (f b)
- class (CoCartesian r, Cartesian t, Functor f r t, Object t (f (ZeroObject r))) => SumToProduct f r t where
Documentation
module Control.Category.Constrained
Functors
class (Category r, Category t, Object t (f (UnitObject r))) => Functor f r t | f r -> t, f t -> r where Source
Functor f => Functor f (->) (->) | |
(Functor [] k k, o [UnitObject k]) => Functor [] (ConstrainedCategory k o) (ConstrainedCategory k o) |
constrainedFmap :: (Category r, Category t, o a, o b, o (f a), o (f b)) => (r a b -> t (f a) (f b)) -> ConstrainedCategory r o a b -> ConstrainedCategory t o (f a) (f b) Source
[Co]product mapping
class (CoCartesian r, Cartesian t, Functor f r t, Object t (f (ZeroObject r))) => SumToProduct f r t where Source
It is fairly common for functors (typically, container-like) to map Either
to tuples in a natural way, thus "separating the variants".
This is related to Foldable
(with list and tuple monoids), but rather more effective.
sum2product :: (ObjectSum r a b, ObjectPair t (f a) (f b)) => t (f (a + b)) (f a, f b) Source
sum2product ≡ mapEither id
mapEither :: (Object r a, ObjectSum r b c, Object t (f a), ObjectPair t (f b) (f c)) => r a (b + c) -> t (f a) (f b, f c) Source
mapEither f ≡ sum2product . fmap f
filter :: (Object r a, Object r Bool, Object t (f a)) => r a Bool -> t (f a) (f a) Source
SumToProduct [] (->) (->) | |
(o (), o [()], o Void, o [Void]) => SumToProduct [] (ConstrainedCategory (->) o) (ConstrainedCategory (->) o) |