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

Copyright(c) 2014 Justus Sagemüller
LicenseGPL v3 (see COPYING)
Maintainer(@) sagemueller $ geo.uni-koeln.de
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Foldable.Constrained

Description

 
Synopsis

Documentation

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 Foldable f => Foldable f (->) (->): in this case, it would prevent some genarality. See below for how to define such an instance manually.

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), Semigroup m, Monoid m, Object k m, Object l m) => (a `k` m) -> t a `l` m Source #

Instances
Foldable [] ((->) :: Type -> Type -> Type) ((->) :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Foldable.Constrained

Methods

ffoldl :: (ObjectPair (->) a b, ObjectPair (->) a [b]) => ((a, b) -> a) -> (a, [b]) -> a Source #

foldMap :: (Object (->) a, Object (->) [a], Semigroup m, Monoid m, Object (->) m, Object (->) m) => (a -> m) -> [a] -> m Source #

Foldable Maybe ((->) :: Type -> Type -> Type) ((->) :: Type -> Type -> Type) Source # 
Instance details

Defined in Data.Foldable.Constrained

Methods

ffoldl :: (ObjectPair (->) a b, ObjectPair (->) a (Maybe b)) => ((a, b) -> a) -> (a, Maybe b) -> a Source #

foldMap :: (Object (->) a, Object (->) (Maybe a), Semigroup m, Monoid m, Object (->) m, Object (->) m) => (a -> m) -> Maybe a -> m Source #

(Foldable f s t, WellPointed s, WellPointed t, Functor f (o s) (o t)) => Foldable f (o s) (o t) Source # 
Instance details

Defined in Data.Foldable.Constrained

Methods

ffoldl :: (ObjectPair (o s) a b, ObjectPair (o t) a (f b)) => (o s) (a, b) a -> (o t) (a, f b) a Source #

foldMap :: (Object (o s) a, Object (o t) (f a), Semigroup m, Monoid m, Object (o s) m, Object (o t) m) => (o s) a m -> (o t) (f a) m Source #

fold :: (Foldable t k k, Monoid m, Semigroup m, Object k m, Object k (t m)) => t m `k` m 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 #

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] Source #