constrained-categories- Constrained clones of the category-theory type classes, using ConstraintKinds.

Copyright(c) 2014 Justus Sagemüller
LicenseGPL v3 (see COPYING)
Maintainer(@) sagemueller $
Safe HaskellTrustworthy








class (Category r, Category t, Object t (f (UnitObject r))) => Functor f r t | f r -> t, f t -> r where Source


fmap :: (Object r a, Object t (f a), Object r b, Object t (f b)) => r a b -> t (f a) (f b) Source

(<$>) :: (Functor f r (->), Object r a, Object r b) => r a b -> f a -> f b infixl 4 Source

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 [] (->) (->) Source 
(o (), o [()], o Void, o [Void]) => SumToProduct [] (ConstrainedCategory (->) o) (ConstrainedCategory (->) o) Source