Copyright | (c) 2014 Justus Sagemüller |
---|---|
License | GPL v3 (see COPYING) |
Maintainer | (@) sagemueller $ geo.uni-koeln.de |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Data.Foldable.Constrained
Description
- module Control.Category.Constrained
- class Functor t k l => Foldable t k l where
- ffoldl :: (ObjectPair k a b, ObjectPair l a (t b)) => k (a, b) a -> l (a, t b) a
- foldMap :: (Object k a, Object l (t a), Monoid m, Object k m, Object l m) => (a `k` m) -> t a `l` m
- fold :: (Foldable t k k, Monoid m, Object k m, Object k (t m)) => t m `k` m
- traverse_ :: forall t k l o f a b uk ul. (Foldable t k l, PreArrow k, PreArrow l, Monoidal f l l, Monoidal f k k, ObjectPair l (f ul) (t a), ObjectPair k (f ul) a, ObjectPair l ul (t a), ObjectPair l (t a) ul, ObjectPair k b ul, Object k (f b), ObjectPair k (f ul) (f ul), ObjectPair k ul ul, uk ~ UnitObject k, ul ~ UnitObject l, uk ~ ul) => (a `k` f b) -> t a `l` f ul
- mapM_ :: forall t k o f a b u. (Foldable t k k, WellPointed k, Monoidal f k k, u ~ UnitObject k, ObjectPair k (f u) (t a), ObjectPair k (f u) a, ObjectPair k u (t a), ObjectPair k (t a) u, ObjectPair k (f u) (f u), ObjectPair k u u, ObjectPair k b u, Object k (f b)) => (a `k` f b) -> t a `k` f u
- forM_ :: forall t k l f a b uk ul. (Foldable t k l, Monoidal f l l, Monoidal f k k, Function l, Arrow k (->), Arrow l (->), ul ~ UnitObject l, uk ~ UnitObject k, uk ~ ul, ObjectPair l ul ul, ObjectPair l (f ul) (f ul), ObjectPair l (f ul) (t a), ObjectPair l ul (t a), ObjectPair l (t a) ul, ObjectPair l (f ul) a, ObjectPair k b (f b), ObjectPair k b ul, ObjectPair k uk uk, ObjectPair k (f uk) a, ObjectPair k (f uk) (f uk)) => t a -> (a `k` f b) -> f uk
- sequence_ :: forall t k l m a b uk ul. (Foldable t k l, Arrow k (->), Arrow l (->), uk ~ UnitObject k, ul ~ UnitObject l, uk ~ ul, Monoidal m k k, Monoidal m l l, ObjectPair k a uk, ObjectPair k (t (m a)) uk, ObjectPair k uk uk, ObjectPair k (m uk) (m uk), ObjectPair k (t (m a)) ul, ObjectPair l (m ul) (t (m a)), ObjectPair l ul (t (m a)), ObjectPair l (m uk) (t (m a)), ObjectPair l (t (m a)) ul, ObjectPair k (m uk) (m a)) => t (m a) `l` m uk
- concatMap :: (Foldable f k l, Object k a, Object k [b], Object l (f a), Object l [b]) => (a `k` [b]) -> f a `l` [b]
Documentation
module Control.Category.Constrained
class Functor t k l => Foldable t k l where Source
Foldable class, generalised to use arrows in categories other than ->
. This changes the interface
somewhat – in particular, foldr
relies on currying and hence can't really be expressed in
a category without exponential objects; however the monoidal folds come out quite nicely. (Of course,
it's debatable how much sense the Hask-Monoid
class even makes in other categories.)
Unlike with the Functor
classes, there is no derived instance
:
in this case, it would prevent some genarality.
See below for how to define such an instance manually.Foldable
f => Foldable
f (->) (->)
Methods
ffoldl :: (ObjectPair k a b, ObjectPair l a (t b)) => k (a, b) a -> l (a, t b) a Source
foldMap :: (Object k a, Object l (t a), Monoid m, Object k m, Object l m) => (a `k` m) -> t a `l` m Source
Instances
Foldable [] (->) (->) Source | |
Foldable Maybe (->) (->) Source | |
(Foldable f s t, WellPointed s, WellPointed t, Functor f (ConstrainedCategory s o) (ConstrainedCategory t o)) => Foldable f (ConstrainedCategory s o) (ConstrainedCategory t o) Source |
traverse_ :: forall t k l o f a b uk ul. (Foldable t k l, PreArrow k, PreArrow l, Monoidal f l l, Monoidal f k k, ObjectPair l (f ul) (t a), ObjectPair k (f ul) a, ObjectPair l ul (t a), ObjectPair l (t a) ul, ObjectPair k b ul, Object k (f b), ObjectPair k (f ul) (f ul), ObjectPair k ul ul, uk ~ UnitObject k, ul ~ UnitObject l, uk ~ ul) => (a `k` f b) -> t a `l` f ul Source
Despite the ridiculous-looking signature, this is in fact equivalent
to traverse_
within Hask.
mapM_ :: forall t k o f a b u. (Foldable t k k, WellPointed k, Monoidal f k k, u ~ UnitObject k, ObjectPair k (f u) (t a), ObjectPair k (f u) a, ObjectPair k u (t a), ObjectPair k (t a) u, ObjectPair k (f u) (f u), ObjectPair k u u, ObjectPair k b u, Object k (f b)) => (a `k` f b) -> t a `k` f u Source
The distinction between mapM_
and traverse_
doesn't really make sense
on grounds of Monoidal
/ Applicative
vs Monad
, but it has in fact some
benefits to restrict this to endofunctors, to make the constraint list
at least somewhat shorter.
forM_ :: forall t k l f a b uk ul. (Foldable t k l, Monoidal f l l, Monoidal f k k, Function l, Arrow k (->), Arrow l (->), ul ~ UnitObject l, uk ~ UnitObject k, uk ~ ul, ObjectPair l ul ul, ObjectPair l (f ul) (f ul), ObjectPair l (f ul) (t a), ObjectPair l ul (t a), ObjectPair l (t a) ul, ObjectPair l (f ul) a, ObjectPair k b (f b), ObjectPair k b ul, ObjectPair k uk uk, ObjectPair k (f uk) a, ObjectPair k (f uk) (f uk)) => t a -> (a `k` f b) -> f uk Source
sequence_ :: forall t k l m a b uk ul. (Foldable t k l, Arrow k (->), Arrow l (->), uk ~ UnitObject k, ul ~ UnitObject l, uk ~ ul, Monoidal m k k, Monoidal m l l, ObjectPair k a uk, ObjectPair k (t (m a)) uk, ObjectPair k uk uk, ObjectPair k (m uk) (m uk), ObjectPair k (t (m a)) ul, ObjectPair l (m ul) (t (m a)), ObjectPair l ul (t (m a)), ObjectPair l (m uk) (t (m a)), ObjectPair l (t (m a)) ul, ObjectPair k (m uk) (m a)) => t (m a) `l` m uk Source