Copyright | (c) 2014 Justus Sagemüller |
---|---|
License | GPL v3 (see COPYING) |
Maintainer | (@) jsag $ hvl.no |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Synopsis
- class (Category r, Category t) => 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)) -> (o ⊢ r) a b -> (o ⊢ t) (f a) (f b)
- class (CoCartesian r, Cartesian t, Functor f r t, Object t (f (ZeroObject r))) => SumToProduct f r t where
Functors
class (Category r, Category t) => Functor f r t | f r -> t, f t -> r where Source #
Instances
constrainedFmap :: (Category r, Category t, o a, o b, o (f a), o (f b)) => (r a b -> t (f a) (f b)) -> (o ⊢ r) a b -> (o ⊢ t) (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 #
Instances
(o (), o Void, o [Void]) => SumToProduct [] (o ⊢ (->)) (o ⊢ (->)) Source # | |
Defined in Control.Functor.Constrained sum2product :: (ObjectSum (o ⊢ (->)) a b, ObjectPair (o ⊢ (->)) [a] [b]) => (o ⊢ (->)) [a + b] ([a], [b]) Source # mapEither :: (Object (o ⊢ (->)) a, ObjectSum (o ⊢ (->)) b c, Object (o ⊢ (->)) [a], ObjectPair (o ⊢ (->)) [b] [c]) => (o ⊢ (->)) a (b + c) -> (o ⊢ (->)) [a] ([b], [c]) Source # filter :: (Object (o ⊢ (->)) a, Object (o ⊢ (->)) Bool, Object (o ⊢ (->)) [a]) => (o ⊢ (->)) a Bool -> (o ⊢ (->)) [a] [a] Source # | |
SumToProduct [] (->) (->) Source # | |
Defined in Control.Functor.Constrained sum2product :: (ObjectSum (->) a b, ObjectPair (->) [a] [b]) => [a + b] -> ([a], [b]) Source # mapEither :: (Object (->) a, ObjectSum (->) b c, Object (->) [a], ObjectPair (->) [b] [c]) => (a -> (b + c)) -> [a] -> ([b], [c]) Source # filter :: (Object (->) a, Object (->) Bool, Object (->) [a]) => (a -> Bool) -> [a] -> [a] Source # |